Eigen PartialPivLU example won't compile - c++

I am trying to compile the Eigen3 PartialPivLU example
MatrixXd A(2,2);
A << 2, -1, 1, 3;
PartialPivLU >> lu(A);
but I get compiler errors (see below).
If I remove the "Ref<> it compiles OK. Does anyone know how to use PartialPivLU with Ref<>?
Thanks
Steve
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/LU:23:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:2,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h: In instantiation of 'class Eigen::PartialPivLU<Eigen::Ref<Eigen::Matrix<double, -1, -1> > >':
test3.cc:9:36: required from here
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h:52:10: error: 'Options' is not a member of 'Eigen::PartialPivLU<Eigen::Ref<Eigen::Matrix<double, -1, -1> > >::MatrixType {aka Eigen::Ref<Eigen::Matrix<double, -1, -1> >}'
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h: In instantiation of 'Eigen::PartialPivLU<MatrixType>::PartialPivLU(const MatrixType&) [with _MatrixType = Eigen::Ref<Eigen::Matrix<double, -1, -1> >; Eigen::PartialPivLU<MatrixType>::MatrixType = Eigen::Ref<Eigen::Matrix<double, -1, -1> >]':
test3.cc:9:36: required from here
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h:213:26: error: no matching function for call to 'Eigen::Ref<Eigen::Matrix<double, -1, -1> >::Ref(Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, -1> >, 0>::Index, Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, -1> >, 0>::Index)'
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h:213:26: note: candidates are:
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/Core:308:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:1,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:211:12: note: template<class Derived> Eigen::Ref::Ref(const Eigen::DenseBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<_PlainObjectType, _Options, _StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*)
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:211:12: note: template argument deduction/substitution failed:
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/LU:23:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:2,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h:213:26: note: mismatched types 'const Eigen::DenseBase<Derived>' and 'Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, -1> >, 0>::Index {aka long int}'
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/Core:308:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:1,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:204:12: note: template<class Derived> Eigen::Ref::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<_PlainObjectType, _Options, _StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*)
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:204:12: note: template argument deduction/substitution failed:
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/LU:23:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:2,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h:213:26: note: mismatched types 'Eigen::PlainObjectBase<OtherDerived>' and 'Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, -1> >, 0>::Index {aka long int}'
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/Core:308:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:1,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:194:12: note: template<class Derived> Eigen::Ref::Ref(const Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<_PlainObjectType, _Options, _StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*)
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:194:12: note: template argument deduction/substitution failed:
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/LU:23:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:2,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/LU/PartialPivLU.h:213:26: note: mismatched types 'const Eigen::PlainObjectBase<OtherDerived>' and 'Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, -1> >, 0>::Index {aka long int}'
In file included from /apps/eigen/3.2.8/include/eigen3/Eigen/Core:308:0,
from /apps/eigen/3.2.8/include/eigen3/Eigen/Dense:1,
from test3.cc:2:
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:188:76: note: Eigen::Ref<Eigen::Matrix<double, -1, -1> >::Ref(const Eigen::Ref<Eigen::Matrix<double, -1, -1> >&)
/apps/eigen/3.2.8/include/eigen3/Eigen/src/Core/Ref.h:188:76: note: candidate expects 1 argument, 2 provided

As chtz noted, the problem was the version of Eigen I was using. You need to use Eigen 3.3 or above.

Related

c++ compilation terminal in file included error/warning

I have a c++ program that outputs what seems to be what I want but i am unsure if the values are correct as some of them are constantly zero which seems a bit suspicious to me. The program uses a C++ implementation of Giraffe found on github at https://github.com/enlighter/giraffe/tree/f3609a7b20d9817bdc543db6832148f26524c298 . The only thing weird that i noticed is that when i compile using VSC, i get a bunch of messages in the terminal prior to the output. I think they are warnings? but i'm not sure as it is my first time using VSC. Below is a log dump of what appears in the terminal. The correct output starts from GLOBAL 0; onwards in the screenshot.
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:302,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Dense:1,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:23,
from ann/ann.h:39,
from ann/features_conv.h:29,
from own.cpp:43:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument '__m128' [-Wignored-attributes]
60 | template<> struct is_arithmetic<__m128> { enum { value = true }; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignoring attributes on template argument '__m128i' [-Wignored-attributes]
61 | template<> struct is_arithmetic<__m128i> { enum { value = true }; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:62:40: warning: ignoring attributes on template argument '__m128d' [-Wignored-attributes]
62 | template<> struct is_arithmetic<__m128d> { enum { value = true }; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:147:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
147 | template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4}; typedef Packet4f half; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:148:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
148 | template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2}; typedef Packet2d half; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:149:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
149 | template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4}; typedef Packet4i half; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:468:37: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
468 | struct protate_impl<offset, Packet4f>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:476:37: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
476 | struct protate_impl<offset, Packet4i>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:484:37: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
484 | struct protate_impl<offset, Packet2d>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:756:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
756 | struct palign_impl<Offset,Packet4f>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:779:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
779 | struct palign_impl<Offset,Packet4i>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:802:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
802 | struct palign_impl<Offset,Packet2d>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:816:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
816 | ptranspose(PacketBlock<Packet4f,4>& kernel) {
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:821:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
821 | ptranspose(PacketBlock<Packet2d,2>& kernel) {
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:828:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
828 | ptranspose(PacketBlock<Packet4i,4>& kernel) {
| ^
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:304:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:233:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
233 | template<> struct conj_helper<Packet4f, Packet2cf, false,false>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:242:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
242 | template<> struct conj_helper<Packet2cf, Packet4f, false,false>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:435:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
435 | template<> struct conj_helper<Packet2d, Packet1cd, false,false>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:444:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
444 | template<> struct conj_helper<Packet1cd, Packet2d, false,false>
| ^
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:328:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, 4, 1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<float>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:22:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:344:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h: In instantiation of 'class Eigen::DenseStorage<float, 4, 4, 1, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:129:113: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<float>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:22:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:38:38: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
38 | bool Match = bool((Size%unpacket_traits<Packet>::size)==0),
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:39:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
39 | bool TryHalf = bool(int(unpacket_traits<Packet>::size) > 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::unpacket_traits<__vector(4) float>::half' {aka '__m128'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:64:60: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
64 | int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
65 | : compute_default_alignment<T,Size>::value >
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<double, 4, 1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<double, 4, 1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<double, 4, 1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<double, 4, 1>, double, double, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<double, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<double>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:75:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attribute
]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h: In instantiation of 'class Eigen::DenseStorage<double, 4, 4, 1, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:129:113: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<double, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<double>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:75:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:38:38: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
38 | bool Match = bool((Size%unpacket_traits<Packet>::size)==0),
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:39:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
39 | bool TryHalf = bool(int(unpacket_traits<Packet>::size) > 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::unpacket_traits<__vector(2) double>::half' {aka '__m128d'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:64:60: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
64 | int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
65 | : compute_default_alignment<T,Size>::value >
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 1, -1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 1, -1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 1, -1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, 1, -1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, 1, -1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Map.h:75:53: required from 'struct Eigen::internal::traits<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/ForwardDeclarations.h:32:48: required from 'struct Eigen::internal::accessors_level<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/ForwardDeclarations.h:116:75: required from 'class Eigen::Map<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:169:52: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Map<Eigen::Matrix<float, 1, -1> >, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MapBase.h:27:34: required from 'class Eigen::MapBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 0>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MapBase.h:171:34: required from 'class Eigen::MapBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Map.h:89:79: required from 'class Eigen::Map<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:169:52: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/SparseCore:30,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Sparse:19,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:24:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseMatrixBase.h: In instantiation of 'class Eigen::SparseMatrixBase<Eigen::SparseMatrix<float, 0, int> >':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseCompressedBase.h:26:7: required from 'class Eigen::SparseCompressedBase<Eigen::SparseMatrix<float, 0, int> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseMatrix.h:92:7: required from 'class Eigen::SparseMatrix<float, 0, int>'
ann/ann.h:61:44: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseMatrixBase.h:42:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
42 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, -1, -1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, -1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, -1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, -1, -1>'
ann/ann.h:82:50: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1, 1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1, 1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1, 1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, -1, -1, 1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, -1, -1, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, -1, -1, 1>'
ann/ann_impl.h:180:99: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/ArrayBase.h:39:34: required from 'class Eigen::ArrayBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/ArrayWrapper.h:41:7: required from 'class Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >'
ann/ann_impl.h:337:43: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/ArrayBase.h:39:34: required from 'class Eigen::ArrayBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> > >'
I have attached a screenshot if it helps. Not sure what the highlighted purple means?
Heres an album of the terminal output: https://imgur.com/a/QIi3X81
Are the purple messages warnings that I need to resolve? Im still getting an output but not sure if these warnings are causing some incorrect values. Seems like all of them are a result of wignoredattribute?

"reshape()" function in Eigen tensor does not compile

I want to use "reshape()" fuction in Eigen unsupported tensor, but my source code cannot be compiled.
The compilation was done as follows.
g++ -std=c++14 -I (path to Eigen) eigen_practice.cpp -o eigen_practice
and here is my source code.
# include "unsupported/Eigen/CXX11/Tensor"
using namespace Eigen;
int main(){
 Tensor<float, 2> input(7, 11);
 Eigen::array<int, 3> three_dims{{7, 11, 1}};
 Tensor<float, 3> result = input.reshape(three_dims);
 return 0;
}
And here is the error messeage.
In file included from eigen_practice.cpp:12:
In file included from /Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/Tensor:145:
/Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:397:7: error:
no matching member function for call to 'resize'
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, Defaul...
^~~~~~
eigen_practice.cpp:63:28: note: in instantiation of function template
specialization 'Eigen::Tensor<float, 3, 0,
long>::Tensor<Eigen::TensorReshapingOp<const std::__1::array<int, 3>,
Eigen::Tensor<float, 2, 0, long> > >' requested here
Tensor<float, 3> result = input.reshape(three_dims);
^
/Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:423:10: note:
candidate function template not viable: no known conversion from 'const
Eigen::TensorEvaluator<const Eigen::TensorAssignOp<Eigen::Tensor<float, 3,
0, long>, const Eigen::TensorReshapingOp<const std::__1::array<int, 3>,
Eigen::Tensor<float, 2, 0, long> > >, Eigen::DefaultDevice>::Dimensions'
(aka 'const std::__1::array<int, 3>') to 'Eigen::Tensor<float, 3, 0,
long>::Index' (aka 'long') for 1st argument
void resize(Index firstDimension, IndexTypes... otherDimensions)
^
/Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:432:28: note:
candidate function not viable: no known conversion from
'array<int, [...]>' to 'const array<long, [...]>' for 1st argument
EIGEN_DEVICE_FUNC void resize(const array<Index, NumIndices>& dimensions)
^
/Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:450:28: note:
candidate function not viable: no known conversion from 'const
Eigen::TensorEvaluator<const Eigen::TensorAssignOp<Eigen::Tensor<float, 3,
0, long>, const Eigen::TensorReshapingOp<const std::__1::array<int, 3>,
Eigen::Tensor<float, 2, 0, long> > >, Eigen::DefaultDevice>::Dimensions'
(aka 'const std::__1::array<int, 3>') to 'const
DSizes<Eigen::Tensor<float, 3, 0, long>::Index, NumIndices>' (aka 'const
DSizes<long, NumIndices>') for 1st argument
EIGEN_DEVICE_FUNC void resize(const DSizes<Index, NumIndices>& dimensions) {
^
/Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:479:10: note:
candidate template ignored: could not match 'Sizes' against 'array'
void resize(const Sizes<Indices...>& dimensions) {
^
/Users/yamamototatsuto/Dropbox/include_for_C++/eigen/unsupported/Eigen/CXX11/src/Tensor/Tensor.h:459:10: note:
candidate function not viable: requires 0 arguments, but 1 was provided
void resize()
^
1 error generated.
This source code is just a copy of what is in the documentation.
(https://eigen.tuxfamily.org/dox/unsupported/eigen_tensors.html)
So it should compile, but it doesn't.
How can I solve it?
And why the error message mentions about "resize()" function?

Eigen ref with child matrix class

I've got the following code:
#include <iostream>
#include <eigen3/Eigen/Dense>
class MyVectorType: public Eigen::Matrix<double, 3, 1> {
public:
MyVectorType(void) :
Eigen::Matrix<double, 3, 1>() {
}
typedef Eigen::Matrix<double, 3, 1> Base;
// This constructor allows you to construct MyVectorType from Eigen expressions
template<typename OtherDerived>
MyVectorType(const Eigen::MatrixBase<OtherDerived>& other) :
Eigen::Matrix<double, 3, 1>(other) {
}
// This method allows you to assign Eigen expressions to MyVectorType
template<typename OtherDerived>
MyVectorType & operator=(const Eigen::MatrixBase<OtherDerived>& other) {
this->Base::operator=(other);
return *this;
}
//other custom methods here
};
void init(Eigen::Ref<MyVectorType>& m) {
for (int i = 0; i < 3; i++)
for (int j = 0; j < 1; j++)
m(i, j) = 1;
}
int main() {
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign, 12,
12> mm(3, 1);
Eigen::Ref<MyVectorType> rr(mm);
init(rr);
std::cout << mm << std::endl;
return 0;
}
I defined my own class but when I try to the Ref class I have the following error from gcc:
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++98 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
In file included from /usr/include/eigen3/Eigen/Core:449:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Map.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:18:8: required from ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:32:54: required from ‘struct Eigen::internal::accessors_level<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:113:75: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Map.h:18:8: error: invalid use of incomplete type ‘struct Eigen::internal::traits<MyVectorType>’
struct traits<Map<PlainObjectType, MapOptions, StrideType> >
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:346:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: note: declaration of ‘struct Eigen::internal::traits<MyVectorType>’
template<typename T> struct traits;
^~~~~~
In file included from /usr/include/eigen3/Eigen/Core:449:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Map.h:30:32: error: incomplete type ‘Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >::TraitsBase {aka Eigen::internal::traits<MyVectorType>}’ used in nested name specifier
Flags0 = TraitsBase::Flags & (~NestByRefBit),
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:348:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h: In instantiation of ‘struct Eigen::internal::is_lvalue<MyVectorType>’:
/usr/include/eigen3/Eigen/src/Core/Map.h:31:47: required from ‘struct Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:18:8: required from ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:32:54: required from ‘struct Eigen::internal::accessors_level<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:113:75: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:642:53: error: incomplete type ‘Eigen::internal::traits<MyVectorType>’ used in nested name specifier
bool(traits<ExpressionType>::Flags & LvalueBit) };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h: In instantiation of ‘class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:58:34: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: error: no type named ‘XprKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:42:62: error: no type named ‘XprKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::dense_xpr_base<Derived>::type Base;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:43:10: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
enum {
^
/usr/include/eigen3/Eigen/src/Core/MapBase.h:43:10: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/MapBase.h:49:61: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::traits<Derived>::StorageKind StorageKind;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:50:56: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::traits<Derived>::Scalar Scalar;
^~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:51:60: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
^~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:52:46: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename NumTraits<Scalar>::Real RealScalar;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:57:22: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
PointerType;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:59:17: error: using-declaration for non-member at class scope
using Base::derived;
^~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:63:17: error: using-declaration for non-member at class scope
using Base::MaxRowsAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:64:17: error: using-declaration for non-member at class scope
using Base::MaxColsAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:65:17: error: using-declaration for non-member at class scope
using Base::MaxSizeAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:66:17: error: using-declaration for non-member at class scope
using Base::IsVectorAtCompileTime;
^~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:67:17: error: using-declaration for non-member at class scope
using Base::Flags;
^~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:68:17: error: using-declaration for non-member at class scope
using Base::IsRowMajor;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:70:17: error: using-declaration for non-member at class scope
using Base::rows;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:71:17: error: using-declaration for non-member at class scope
using Base::cols;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:72:17: error: using-declaration for non-member at class scope
using Base::size;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:73:17: error: using-declaration for non-member at class scope
using Base::coeff;
^~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:74:17: error: using-declaration for non-member at class scope
using Base::coeffRef;
^~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:75:17: error: using-declaration for non-member at class scope
using Base::lazyAssign;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:76:17: error: using-declaration for non-member at class scope
using Base::eval;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:78:17: error: using-declaration for non-member at class scope
using Base::innerStride;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:79:17: error: using-declaration for non-member at class scope
using Base::outerStride;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:80:17: error: using-declaration for non-member at class scope
using Base::rowStride;
^~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:81:17: error: using-declaration for non-member at class scope
using Base::colStride;
^~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:84:25: error: using-declaration for non-member at class scope
using Base::operator=;
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘StorageIndex’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘MaxSizeAtCompileTime’ is not a member of ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘IsVectorAtCompileTime’ is not a member of ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no members matching ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}::derived’ in ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no members matching ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}::const_cast_derived’ in ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘class Eigen::Ref<MyVectorType>’:
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘StorageIndex’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no members matching ‘Eigen::Ref<MyVectorType>::Base {aka Eigen::RefBase<Eigen::Ref<MyVectorType> >}::derived’ in ‘Eigen::Ref<MyVectorType>::Base {aka class Eigen::RefBase<Eigen::Ref<MyVectorType> >}’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no members matching ‘Eigen::Ref<MyVectorType>::Base {aka Eigen::RefBase<Eigen::Ref<MyVectorType> >}::const_cast_derived’ in ‘Eigen::Ref<MyVectorType>::Base {aka class Eigen::RefBase<Eigen::Ref<MyVectorType> >}’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
../main.cpp: In function ‘void init(Eigen::Ref<MyVectorType>&)’:
../main.cpp:26:10: error: no match for call to ‘(Eigen::Ref<MyVectorType>) (int&, int&)’
m(i, j) = 1;
^
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >::match<Eigen::Matrix<double, -1, -1, 0, 12, 12> >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:197:63: required by substitution of ‘template<class Derived> Eigen::Ref<MyVectorType>::Ref(const Eigen::PlainObjectBase<Derived>&, typename Eigen::internal::enable_if<(bool)(Eigen::internal::traits<Eigen::Ref<MyVectorType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:44:25: error: incomplete type ‘Eigen::internal::traits<MyVectorType>’ used in nested name specifier
AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(Unaligned)) || (DerivedAlignment >= int(Alignment)), // FIXME the first condition is not very clear, it should be replaced by the required alignment
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:347:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h: In instantiation of ‘static void Eigen::PlainObjectBase<Derived>::_check_template_params() [with Derived = Eigen::Matrix<double, 3, 1, 0, 12, 12>]’:
/usr/include/eigen3/Eigen/src/Core/Matrix.h:261:35: required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix() [with _Scalar = double; int _Rows = 3; int _Cols = 1; int _Options = 0; int _MaxRows = 12; int _MaxCols = 12]’
../main.cpp:7:58: required from here
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:899:7: error: ‘INVALID_MATRIX_TEMPLATE_PARAMETERS’ is not a member of ‘Eigen::internal::static_assertion<false>’
EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&RowMajor)==RowMajor)
^
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘Eigen::RefBase<Derived>::RefBase() [with Derived = Eigen::Ref<MyVectorType>]’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:208:5: required from ‘Eigen::Ref<PlainObjectType, Options, StrideType>::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>; PlainObjectType = MyVectorType; int Options = 0; StrideType = Eigen::OuterStride<>; typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:86:100: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(int, int, int)’
StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime)
^
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘void Eigen::RefBase<Derived>::construct(Expression&) [with Expression = Eigen::Matrix<double, -1, -1, 0, 12, 12>; Derived = Eigen::Ref<MyVectorType>]’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:210:22: required from ‘Eigen::Ref<PlainObjectType, Options, StrideType>::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>; PlainObjectType = MyVectorType; int Options = 0; StrideType = Eigen::OuterStride<>; typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:101:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, int, Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Index)’
::new (static_cast<Base*>(this)) Base(expr.data(), 1, expr.size());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:106:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Index, int)’
::new (static_cast<Base*>(this)) Base(expr.data(), expr.size(), 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:109:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, Eigen::Index, Eigen::Index)’
::new (static_cast<Base*>(this)) Base(expr.data(), expr.rows(), expr.cols());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
Is possible to pass by reference a dynamic matrix to a fixed one using a custom child class?
Eigen::Ref is not intended to work with own custom types (that would be possible, but is way to complicated for this purpose). Simply use Eigen::Ref<MyVectorType::Base>. Also if a Ref is intended to be an L-value (i.e., writable), you should pass it by-value, like so
void init(Eigen::Ref<MyVectorType::Base> m) {
// ...
That way you don't need to manually generate a temporary when calling init:
int main() {
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign, 12,
12> mm(3, 1);
// Eigen::Ref<MyVectorType> rr(mm); // not necessary!
init(mm); // implicitly generates a temporary `Ref` object
// ...
For more details, see the online documentation of Ref: https://eigen.tuxfamily.org/dox/classEigen_1_1Ref.html

Eigen error associated with triangularView of template

I have the following function that is throwing an error. I can isolate the problem to the line
A.template triangularView<Lower>().solveInPlace(MatrixXd::Identity(p,p)); // the problem line
But I am having trouble figuring out how what the problem is an how to fix it.
template <typename T, typename RNG>
inline void rInvWishRevCholesky_thread_inplace(Eigen::MatrixBase<T>& A,
const int v,
const Eigen::Ref<const Eigen::MatrixXd>& Psi,
RNG& rng){
int p = Psi.rows();
MatrixXd PsiInv = Psi.llt().solve(MatrixXd::Identity(p,p));
if (v <= p-1)
Rcpp::stop("v must be > Psi.rows - 1");
VectorXd z(p*(p-1)/2);
fillUnitNormal_thread(z, rng);
MatrixXd X = MatrixXd::Zero(p, p);
for (int i=0; i<p; i++){
boost::random::chi_squared_distribution<> rchisq(v-i);
X(i,i) = sqrt(rchisq(rng));
}
int pos = 0;
for (int i=1; i<p; i++){
for (int j=0; j<i; j++){
X(i,j) = z(pos);
pos++;
}
}
A.template noalias() = PsiInv.llt().matrixL()*X;
A.template triangularView<Lower>().solveInPlace(MatrixXd::Identity(p,p)); // the problem line
A.template transposeInPlace();
}
Here is the error message:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:496:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/SolveTriangular.h: In instantiation of 'void Eigen::TriangularViewImpl<_MatrixType, _Mode, Eigen::Dense>::solveInPlace(const Eigen::MatrixBase<OtherDerived>&) const [with int Side = 1; OtherDerived = Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >; _MatrixType = Eigen::Matrix<double, -1, -1>; unsigned int _Mode = 1]':
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/TriangularMatrix.h:511:37: required from 'void Eigen::TriangularViewImpl<_MatrixType, _Mode, Eigen::Dense>::solveInPlace(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >; _MatrixType = Eigen::Matrix<double, -1, -1>; unsigned int _Mode = 1]'
../inst/include/MatDist_thread.h:153:3: required from 'void rInvWishRevCholesky_thread_inplace(Eigen::MatrixBase<Derived>&, int, const Eigen::Ref<const Eigen::Matrix<double, -1, -1> >&, RNG&) [with T = Eigen::Matrix<double, -1, -1>; RNG = boost::random::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>]'
MongrelCollapsed_Uncollapse.cpp:162:72: required from here
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/SolveTriangular.h:182:11: error: use of deleted function 'Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >& Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >::operator=(const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >&)'
other = otherCopy;
~~~~~~^~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:463:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/CwiseNullaryOp.h:60:7: note: 'Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >& Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >::operator=(const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >&)' is implicitly deleted because the default definition would be ill-formed:
class CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator
^~~~~~~~~~~~~~
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/CwiseNullaryOp.h:60:7: error: 'Eigen::internal::no_assignment_operator& Eigen::internal::no_assignment_operator::operator=(const Eigen::internal::no_assignment_operator&)' is private within this context
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:367:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:92:29: note: declared private here
no_assignment_operator& operator=(const no_assignment_operator&);
^~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:463:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/CwiseNullaryOp.h:60:7: error: passing 'const Eigen::internal::variable_if_dynamic<long int, -1>' as 'this' argument discards qualifiers [-fpermissive]
class CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator
^~~~~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:367:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:115:28: note: in call to 'Eigen::internal::variable_if_dynamic<long int, -1>& Eigen::internal::variable_if_dynamic<long int, -1>::operator=(const Eigen::internal::variable_if_dynamic<long int, -1>&)'
template<typename T> class variable_if_dynamic<T, Dynamic>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:463:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/CwiseNullaryOp.h:60:7: error: passing 'const Eigen::internal::variable_if_dynamic<long int, -1>' as 'this' argument discards qualifiers [-fpermissive]
class CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator
^~~~~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:367:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/XprHelper.h:115:28: note: in call to 'Eigen::internal::variable_if_dynamic<long int, -1>& Eigen::internal::variable_if_dynamic<long int, -1>::operator=(const Eigen::internal::variable_if_dynamic<long int, -1>&)'
template<typename T> class variable_if_dynamic<T, Dynamic>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:463:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/CwiseNullaryOp.h:60:7: error: passing 'const Eigen::internal::scalar_identity_op<double>' as 'this' argument discards qualifiers [-fpermissive]
class CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator
^~~~~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:425:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/functors/NullaryFunctors.h:31:34: note: in call to 'Eigen::internal::scalar_identity_op<double>& Eigen::internal::scalar_identity_op<double>::operator=(const Eigen::internal::scalar_identity_op<double>&)'
template<typename Scalar> struct scalar_identity_op {
^~~~~~~~~~~~~~~~~~
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:496:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/SolveTriangular.h: In instantiation of 'static void Eigen::internal::triangular_solver_selector<Lhs, Rhs, Side, Mode, 0, -1>::run(const Lhs&, Rhs&) [with Lhs = Eigen::Matrix<double, -1, -1>; Rhs = Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >; int Side = 1; int Mode = 1]':
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/SolveTriangular.h:179:21: required from 'void Eigen::TriangularViewImpl<_MatrixType, _Mode, Eigen::Dense>::solveInPlace(const Eigen::MatrixBase<OtherDerived>&) const [with int Side = 1; OtherDerived = Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >; _MatrixType = Eigen::Matrix<double, -1, -1>; unsigned int _Mode = 1]'
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/TriangularMatrix.h:511:37: required from 'void Eigen::TriangularViewImpl<_MatrixType, _Mode, Eigen::Dense>::solveInPlace(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >; _MatrixType = Eigen::Matrix<double, -1, -1>; unsigned int _Mode = 1]'
../inst/include/MatDist_thread.h:153:3: required from 'void rInvWishRevCholesky_thread_inplace(Eigen::MatrixBase<Derived>&, int, const Eigen::Ref<const Eigen::Matrix<double, -1, -1> >&, RNG&) [with T = Eigen::Matrix<double, -1, -1>; RNG = boost::random::mersenne_twister_engine<unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>]'
MongrelCollapsed_Uncollapse.cpp:162:72: required from here
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/SolveTriangular.h:102:81: error: no matching function for call to 'Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >::coeffRef(int, int)'
::run(size, othersize, &actualLhs.coeffRef(0,0), actualLhs.outerStride(), &rhs.coeffRef(0,0), rhs.outerStride(), blocking);
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:434:0,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:30,
from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25,
from ../inst/include/MatrixAlgebra.h:4,
from ../inst/include/mongrel.h:17,
from MongrelCollapsed_Uncollapse.cpp:1:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:273:10: note: candidate: void Eigen::DenseCoeffsBase<Derived, 0>::coeffRef() [with Derived = Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<double>, Eigen::Matrix<double, -1, -1> >]
void coeffRef();
^~~~~~~~
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:273:10: note: candidate expects 0 arguments, 2 provided
make: *** [MongrelCollapsed_Uncollapse.o] Error 1
ERROR: compilation failed for package ‘mongrel’
* removing ‘/private/var/folders/x1/9_lpy_fs0kvg0p88td6_df200000gq/T/Rtmp7seVyi/devtools_install_1385330e7ebb0/mongrel’
Error: Command failed (1)
Any advice would be much appreciated!
solveInPlace requires its argument to be writable, MatrixXd::Identity(p,p) is a read-only expression. (Where would you expect to get the result from that function?)
Maybe what you want is this?
A.noalias() = (PsiInv.llt().matrixL()*X).transpose()
.template triangularView<Upper>().solve(MatrixXd::Identity(p,p));

Invoking Template Function using Random Access Iterator

As part of an MOC, I am implementing the merge_sort subroutine, and just for curiosity's sake, I would like to implement it using a function signature similar to what std::sort does.
The code I have so far is as follows.
#include <iostream>
#include <vector>
template <typename T>
bool read_number_list(const std::string& filename, std::vector<T>& output_array){
// ... read number list into an array
return true;
}
template<typename RandomAccessIterator>
void merge_sort_array (RandomAccessIterator first, RandomAccessIterator last, std::vector<decltype(*first)>& merge_array){
// ... merge routine
}
template<typename RandomAccessIterator>
void sort_array (RandomAccessIterator first, RandomAccessIterator last){
std::vector<decltype(*first)> merge_array;
merge_array.assign(first, last);
merge_sort_array(first, last, merge_array);
}
int main(){
std::vector<int> number_array;
read_number_list<int>("file.txt", number_array);
sort_array(number_array.begin(), number_array.end());
return 0;
}
I am seeing errors in the step where I make a copy of the array to be sorted, and also at the point where I invoke the merge_sort_array method. As is customary in templated code, I get the following plethora of errors (which I find quite inscrutable):
In file included from /usr/include/x86_64-linux-gnu/c++/4.8/bits/c++allocator.h:33:0,
from /usr/include/c++/4.8/bits/allocator.h:46,
from /usr/include/c++/4.8/string:41,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/ext/new_allocator.h: In instantiation of 'class __gnu_cxx::new_allocator<int&>':
/usr/include/c++/4.8/bits/allocator.h:92:11: required from 'class std::allocator<int&>'
/usr/include/c++/4.8/bits/alloc_traits.h:90:43: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/ext/new_allocator.h:63:26: error: forming pointer to reference type 'int&'
typedef _Tp* pointer;
^
/usr/include/c++/4.8/ext/new_allocator.h:64:26: error: forming pointer to reference type 'int&'
typedef const _Tp* const_pointer;
^
In file included from /usr/include/c++/4.8/string:41:0,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/bits/allocator.h: In instantiation of 'class std::allocator<int&>':
/usr/include/c++/4.8/bits/alloc_traits.h:90:43: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/allocator.h:97:26: error: forming pointer to reference type 'int&'
typedef _Tp* pointer;
^
/usr/include/c++/4.8/bits/allocator.h:98:26: error: forming pointer to reference type 'int&'
typedef const _Tp* const_pointer;
^
In file included from /usr/include/c++/4.8/ext/alloc_traits.h:36:0,
from /usr/include/c++/4.8/bits/stl_construct.h:61,
from /usr/include/c++/4.8/bits/stl_tempbuf.h:60,
from /usr/include/c++/4.8/bits/stl_algo.h:62,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<std::allocator<int&> >':
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: error: forming pointer to reference type 'std::allocator_traits<std::allocator<int&> >::value_type {aka int&}'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
^
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
^
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: note: template<class _Tp> static typename _Tp::pointer std::allocator_traits<_Alloc>::_S_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
^
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_const_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: note: template<class _Tp> static typename _Tp::const_pointer std::allocator_traits<_Alloc>::_S_const_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_void_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: note: template<class _Tp> static typename _Tp::void_pointer std::allocator_traits<_Alloc>::_S_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h: In substitution of 'template<class _Tp> static typename _Tp::void_pointer std::allocator_traits<_Alloc>::_S_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>] [with _Tp = std::allocator<int&>]':
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: error: no type named 'void_pointer' in 'class std::allocator<int&>'
/usr/include/c++/4.8/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<std::allocator<int&> >':
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_const_void_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: note: template<class _Tp> static typename _Tp::const_void_pointer std::allocator_traits<_Alloc>::_S_const_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h: In substitution of 'template<class _Tp> static typename _Tp::const_void_pointer std::allocator_traits<_Alloc>::_S_const_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>] [with _Tp = std::allocator<int&>]':
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: error: no type named 'const_void_pointer' in 'class std::allocator<int&>'
In file included from /usr/include/c++/4.8/bits/stl_construct.h:61:0,
from /usr/include/c++/4.8/bits/stl_tempbuf.h:60,
from /usr/include/c++/4.8/bits/stl_algo.h:62,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/ext/alloc_traits.h: In instantiation of 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >':
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/ext/alloc_traits.h:137:23: error: no members matching '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka std::allocator_traits<std::allocator<int&> >}::allocate' in '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka struct std::allocator_traits<std::allocator<int&> >}'
using _Base_type::allocate;
^
/usr/include/c++/4.8/ext/alloc_traits.h:138:23: error: no members matching '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka std::allocator_traits<std::allocator<int&> >}::deallocate' in '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka struct std::allocator_traits<std::allocator<int&> >}'
using _Base_type::deallocate;
^
In file included from /usr/include/c++/4.8/vector:64:0,
from /usr/include/c++/4.8/bits/random.h:34,
from /usr/include/c++/4.8/random:50,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of 'class std::vector<int&, std::allocator<int&> >':
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/stl_vector.h:237:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_allocate' in 'std::vector<int&, std::allocator<int&> >::_Base {aka struct std::_Vector_base<int&, std::allocator<int&> >}'
using _Base::_M_allocate;
^
/usr/include/c++/4.8/bits/stl_vector.h:238:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_deallocate' in 'std::vector<int&, std::allocator<int&> >::_Base {aka struct std::_Vector_base<int&, std::allocator<int&> >}'
using _Base::_M_deallocate;
^
/usr/include/c++/4.8/bits/stl_vector.h:878:7: error: forming pointer to reference type 'int&'
data() _GLIBCXX_NOEXCEPT
^
/usr/include/c++/4.8/bits/stl_vector.h:886:7: error: forming pointer to reference type 'int&'
data() const _GLIBCXX_NOEXCEPT
^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: error: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]' cannot be overloaded
push_back(value_type&& __x)
^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: error: with 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]'
push_back(const value_type& __x)
^
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc: In instantiation of 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]':
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:22:46: error: 'merge_sort_array' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
merge_sort_array(first, last, merge_array);
^
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:26:6: note: 'template<class RandomAccessIterator> void merge_sort_array(RandomAccessIterator, RandomAccessIterator, std::vector<decltype (* first)>&)' declared here, later in the translation unit
void merge_sort_array (RandomAccessIterator first, RandomAccessIterator last, std::vector<decltype(*first)>& merge_array){
^
make[2]: *** [src/test/cpp/lib/algorithms/sorting/CMakeFiles/test_inversion_count.dir/test_inversion_count.cc.o] Error 1
make[1]: *** [src/test/cpp/lib/algorithms/sorting/CMakeFiles/test_inversion_count.dir/all] Error 2
make: *** [all] Error 2
What am I doing wrong?
Your problem is the misuse of decltype:
decltype( expression )
yields T& for lvalue expressions of type T, and you cannot have an std::vector<int&>. Thus the error.
To fix that, use typename std::iterator_traits<RandomAccessIterator>::value_type as template parameter instead.