Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102321457
CustomizingEigen_Inheritance.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 19, 12:02
Size
766 B
Mime Type
text/x-c++
Expires
Fri, Feb 21, 12:02 (2 d)
Engine
blob
Format
Raw Data
Handle
24330371
Attached To
rDLMA Diffusion limited mixed aggregation
CustomizingEigen_Inheritance.cpp
View Options
#include <Eigen/Core>
#include <iostream>
class
MyVectorType
:
public
Eigen
::
VectorXd
{
public
:
MyVectorType
(
void
)
:
Eigen
::
VectorXd
()
{}
// This constructor allows you to construct MyVectorType from Eigen expressions
template
<
typename
OtherDerived
>
MyVectorType
(
const
Eigen
::
MatrixBase
<
OtherDerived
>&
other
)
:
Eigen
::
VectorXd
(
other
)
{
}
// This method allows you to assign Eigen expressions to MyVectorType
template
<
typename
OtherDerived
>
MyVectorType
&
operator
=
(
const
Eigen
::
MatrixBase
<
OtherDerived
>&
other
)
{
this
->
Eigen
::
VectorXd
::
operator
=
(
other
);
return
*
this
;
}
};
int
main
()
{
MyVectorType
v
=
MyVectorType
::
Ones
(
4
);
v
(
2
)
+=
10
;
v
=
2
*
v
;
std
::
cout
<<
v
.
transpose
()
<<
std
::
endl
;
}
Event Timeline
Log In to Comment