Eigen 3.4.90
doc
examples
class_CwiseUnaryOp_ptrfun.cpp
Go to the documentation of this file.
1
#include <
Eigen/Core
>
2
#include <iostream>
3
4
// define function to be applied coefficient-wise
5
double
ramp
(
double
x
)
6
{
7
if
(
x
> 0)
8
return
x
;
9
else
10
return
0;
11
}
12
13
int
main
(
int
,
char
**)
14
{
15
Eigen::Matrix4d
m1
=
Eigen::Matrix4d::Random
();
16
std::cout <<
m1
<< std::endl <<
"becomes: "
<< std::endl <<
m1
.unaryExpr(std::ptr_fun(
ramp
)) << std::endl;
17
return
0;
18
}
x
x
Definition:
BiCGSTAB_simple.cpp:7
Core
m1
Matrix3d m1
Definition:
IOFormat.cpp:2
Eigen::DenseBase::Random
static const RandomReturnType Random()
Definition:
Random.h:114
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
Matrix.h:182
main
int main(int, char **)
Definition:
class_CwiseUnaryOp_ptrfun.cpp:13
ramp
double ramp(double x)
Definition:
class_CwiseUnaryOp_ptrfun.cpp:5