Custom scalar type with Eigen : Inverting compiles for 4x4 matrices, but not for 5x5 matrices

55 views Asked by At

So, I'm trying to use Eigen to do some computations with matrices with a custom scalar type (that being elements of a finite field). I have the following code :

#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Core>
#include <cassert>

namespace Eigen
{
    template <short N>
    struct int_mod {
        int_mod() : n(0) {}
        int_mod(int n_) : n((n_+N)%N) {}
        
        int_mod operator-(){ return N-n; }
        int_mod operator+(int_mod i) const { return (n+i.n)%N; }
        int_mod operator*(int_mod i) const { return (n*i.n)%N; }
        int_mod operator-(int_mod i) const { return (n-i.n+N)%N; }
        int_mod operator/(int_mod i) const { 
            int t = 0;
            int newt = n;
            int r = N;
            int newr = i.n;
            
            while(newr != 0) {
                int q = r/newr;
                int temp = newt;
                newt = t-q*temp;
                t = temp;
                temp = newr;
                newr = r-q*temp;
                r = temp;
            }
            
            if(r>1) { throw std::runtime_error("Not invertible"); }
            if(t<0) t = t+N;
            return t;
        }
        
        void operator=(const int_mod& other){ n = other.n; }
        void operator=(const int& other){ n = other; }
        void operator+=(const int_mod& other){ int_mod res = (*this)+other; this->n = res.n; }
        void operator-=(const int_mod& other){ int_mod res = (*this)-other; this->n = res.n; }
        void operator*=(const int_mod& other){ int_mod res = (*this)*other; this->n = res.n; }
        void operator/=(const int_mod& other){ int_mod res = (*this)/other; this->n = res.n; }
        
        bool operator==(int_mod i) const { return n == i.n; }
        
        static constexpr short mod() { return N; }
        
        short n;
    };

    template<short N>
    std::ostream& operator<<(std::ostream& os, int_mod<N> i) { os << i.n; return os; }

    template<short T> struct NumTraits<int_mod<T>> : NumTraits<int>
    {
      typedef int_mod<T> Real;
      typedef int_mod<T> NonInteger;
      typedef int_mod<T> Nested;
     
      enum {
        IsComplex = 0,
        IsInteger = 0,
        IsSigned = 1,
        RequireInitialization = 1,
        ReadCost = 1,
        AddCost = 3,
        MulCost = 3
      };
    };
}

typedef Eigen::Matrix<Eigen::int_mod<3>, 5, 5> MatrixMod;

int main()
{
    MatrixMod m = MatrixMod::Identity();
    
    MatrixMod mi = m.inverse();
    
    std::cout << mi << std::endl;
}

However, I get the following error message :

In file included from EigenTest.cpp:2:
In file included from /usr/local/include/eigen3/Eigen/Dense:1:
In file included from /usr/local/include/eigen3/Eigen/Core:171:
/usr/local/include/eigen3/Eigen/src/Core/MathFunctions.h:1511:10: error: call to function 'abs' that is neither visible in the template definition nor found by argument-dependent lookup
  return abs(x);
         ^
/usr/local/include/eigen3/Eigen/src/Core/functors/UnaryFunctors.h:44:111: note: in instantiation of function template specialization 'Eigen::numext::abs<Eigen::int_mod<3>>' requested here
  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs(a); }
                                                                                                              ^
/usr/local/include/eigen3/Eigen/src/Core/CoreEvaluators.h:583:12: note: in instantiation of member function 'Eigen::internal::scalar_abs_op<Eigen::int_mod<3>>::operator()' requested here
    return m_d.func()(m_d.argImpl.coeff(row, col));
           ^
/usr/local/include/eigen3/Eigen/src/Core/CoreEvaluators.h:1123:22: note: in instantiation of member function 'Eigen::internal::unary_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs_op<Eigen::int_mod<3>>, const Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>::coeff' requested here
    return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
                     ^
/usr/local/include/eigen3/Eigen/src/Core/Redux.h:381:18: note: in instantiation of member function 'Eigen::internal::unary_evaluator<Eigen::Block<const Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs_op<Eigen::int_mod<3>>, const Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>>::coeff' requested here
  { return Base::coeff(IsRowMajor ? outer : inner, IsRowMajor ? inner : outer); }
                 ^
/usr/local/include/eigen3/Eigen/src/Core/Redux.h:128:17: note: in instantiation of member function 'Eigen::internal::redux_evaluator<Eigen::Block<const Eigen::CwiseUnaryOp<Eigen::internal::scalar_abs_op<Eigen::int_mod<3>>, const Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>>::coeffByOuterInner' requested here
    return eval.coeffByOuterInner(outer, inner);
                ^
/usr/local/include/eigen3/Eigen/src/Core/Redux.h:110:75: note: (skipping 19 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
    return func(redux_novec_unroller<Func, Evaluator, Start, HalfLength>::run(eval,func),
                                                                          ^
/usr/local/include/eigen3/Eigen/src/Core/AssignEvaluator.h:890:46: note: in instantiation of member function 'Eigen::internal::Assignment<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>::run' requested here
  Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);
                                             ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:797:17: note: in instantiation of function template specialization 'Eigen::internal::call_assignment_no_alias<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>' requested here
      internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
                ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:594:7: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::_set_noalias<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      _set_noalias(other);
      ^
/usr/local/include/eigen3/Eigen/src/Core/Matrix.h:423:9: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::PlainObjectBase<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      : Base(other.derived())
        ^
EigenTest.cpp:82:17: note: in instantiation of function template specialization 'Eigen::Matrix<Eigen::int_mod<3>, 5, 5>::Matrix<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
        MatrixMod mi = m.inverse();
                       ^
/usr/local/include/eigen3/Eigen/src/Core/MathFunctions.h:1509:1: note: 'abs' should be declared prior to the call site or in namespace 'Eigen'
abs(const T &x) {
^
In file included from EigenTest.cpp:1:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream:43:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/ios:221:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/mutex:191:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/uninitialized_algorithms.h:13:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/copy.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/min.h:12:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/comp.h:47:71: error: invalid operands to binary expression ('const Eigen::int_mod<3>' and 'const Eigen::int_mod<3>')
    bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
                                                                  ~~~ ^ ~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/max.h:33:12: note: in instantiation of member function 'std::__less<Eigen::int_mod<3>>::operator()' requested here
    return __comp(__a, __b) ? __b : __a;
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/max.h:42:19: note: in instantiation of function template specialization 'std::max<Eigen::int_mod<3>, std::__less<Eigen::int_mod<3>>>' requested here
    return _VSTD::max(__a, __b, __less<_Tp>());
                  ^
/usr/local/include/eigen3/Eigen/src/Core/MathFunctions.h:1094:10: note: in instantiation of function template specialization 'std::max<Eigen::int_mod<3>>' requested here
  return max EIGEN_NOT_A_MACRO (x,y);
         ^
/usr/local/include/eigen3/Eigen/src/Core/GenericPacketMath.h:524:57: note: in instantiation of function template specialization 'Eigen::numext::maxi<Eigen::int_mod<3>>' requested here
pmax(const Packet& a, const Packet& b) { return numext::maxi(a, b); }
                                                        ^
/usr/local/include/eigen3/Eigen/src/Core/GenericPacketMath.h:530:90: note: in instantiation of function template specialization 'Eigen::internal::pmax<Eigen::int_mod<3>>' requested here
  return pminmax_impl<NaNPropagation>::run(a, b, EIGEN_BINARY_OP_NAN_PROPAGATION(Packet,(pmax<Packet>)));
                                                                                         ^
/usr/local/include/eigen3/Eigen/src/Core/functors/BinaryFunctors.h:176:22: note: (skipping 11 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
    return internal::pmax<NaNPropagation>(a,b);
                     ^
/usr/local/include/eigen3/Eigen/src/Core/AssignEvaluator.h:890:46: note: in instantiation of member function 'Eigen::internal::Assignment<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>::run' requested here
  Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);
                                             ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:797:17: note: in instantiation of function template specialization 'Eigen::internal::call_assignment_no_alias<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>' requested here
      internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
                ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:594:7: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::_set_noalias<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      _set_noalias(other);
      ^
/usr/local/include/eigen3/Eigen/src/Core/Matrix.h:423:9: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::PlainObjectBase<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      : Base(other.derived())
        ^
EigenTest.cpp:82:17: note: in instantiation of function template specialization 'Eigen::Matrix<Eigen::int_mod<3>, 5, 5>::Matrix<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
        MatrixMod mi = m.inverse();
                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__utility/pair.h:465:1: note: candidate template ignored: could not match 'pair' against 'int_mod'
operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
^
In file included from EigenTest.cpp:2:
In file included from /usr/local/include/eigen3/Eigen/Dense:2:
In file included from /usr/local/include/eigen3/Eigen/LU:29:
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:382:28: error: invalid operands to binary expression ('Score' (aka 'int_mod<3i16>') and 'Score')
      if(biggest_in_corner != Score(0))
         ~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:439:14: note: in instantiation of member function 'Eigen::internal::partial_lu_impl<Eigen::int_mod<3>, 0, int, 5>::unblocked_lu' requested here
      return unblocked_lu(lu, row_transpositions, nb_transpositions);
             ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:519:7: note: in instantiation of member function 'Eigen::internal::partial_lu_impl<Eigen::int_mod<3>, 0, int, 5>::blocked_lu' requested here
    ::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions);
      ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:543:13: note: in instantiation of function template specialization 'Eigen::internal::partial_lu_inplace<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Transpositions<5, 5>>' requested here
  internal::partial_lu_inplace(m_lu, m_rowsTranspositions, nb_transpositions);
            ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:133:7: note: in instantiation of member function 'Eigen::PartialPivLU<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::compute' requested here
      compute();
      ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:315:3: note: in instantiation of function template specialization 'Eigen::PartialPivLU<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::compute<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>' requested here
  compute(matrix.derived());
  ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:604:10: note: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
  return PartialPivLU<PlainObject>(eval());
         ^
/usr/local/include/eigen3/Eigen/src/Core/AssignEvaluator.h:890:46: note: in instantiation of member function 'Eigen::internal::Assignment<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>::run' requested here
  Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);
                                             ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:797:17: note: in instantiation of function template specialization 'Eigen::internal::call_assignment_no_alias<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>' requested here
      internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
                ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:594:7: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::_set_noalias<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      _set_noalias(other);
      ^
/usr/local/include/eigen3/Eigen/src/Core/Matrix.h:423:9: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::PlainObjectBase<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      : Base(other.derived())
        ^
EigenTest.cpp:82:17: note: in instantiation of function template specialization 'Eigen::Matrix<Eigen::int_mod<3>, 5, 5>::Matrix<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
        MatrixMod mi = m.inverse();
                       ^
In file included from EigenTest.cpp:2:
In file included from /usr/local/include/eigen3/Eigen/Dense:1:
In file included from /usr/local/include/eigen3/Eigen/Core:318:
/usr/local/include/eigen3/Eigen/src/Core/Visitor.h:227:14: error: invalid operands to binary expression ('const Scalar' (aka 'const Eigen::int_mod<3>') and 'Scalar' (aka 'Eigen::int_mod<3>'))
    if(value > this->res)
       ~~~~~ ^ ~~~~~~~~~
/usr/local/include/eigen3/Eigen/src/Core/Visitor.h:59:7: note: in instantiation of member function 'Eigen::internal::max_coeff_visitor<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>, 0>::operator()' requested here
      visitor(mat.coeff(i, 0), i, 0);
      ^
/usr/local/include/eigen3/Eigen/src/Core/Visitor.h:129:101: note: in instantiation of member function 'Eigen::internal::visitor_impl<Eigen::internal::max_coeff_visitor<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>, 0>, Eigen::internal::visitor_evaluator<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>>, -1>::run' requested here
  return internal::visitor_impl<Visitor, ThisEvaluator, unroll ? int(SizeAtCompileTime) : Dynamic>::run(thisEval, visitor);
                                                                                                    ^
/usr/local/include/eigen3/Eigen/src/Core/Visitor.h:374:9: note: in instantiation of function template specialization 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>>::visit<Eigen::internal::max_coeff_visitor<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>, 0>>' requested here
  this->visit(maxVisitor);
        ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:501:14: note: in instantiation of function template specialization 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>>::maxCoeff<0, long>' requested here
      return maxCoeff<PropagateFast>(index);
             ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:377:55: note: in instantiation of function template specialization 'Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_score_coeff_op<Eigen::int_mod<3>>, const Eigen::Block<Eigen::Block<Eigen::Ref<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, 5, 1, true>, -1, 1>>>::maxCoeff<long>' requested here
        = lu.col(k).tail(rows-k).unaryExpr(Scoring()).maxCoeff(&row_of_biggest_in_col);
                                                      ^
/usr/local/include/eigen3/Eigen/src/LU/PartialPivLU.h:439:14: note: (skipping 8 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
      return unblocked_lu(lu, row_transpositions, nb_transpositions);
             ^
/usr/local/include/eigen3/Eigen/src/Core/AssignEvaluator.h:890:46: note: in instantiation of member function 'Eigen::internal::Assignment<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>::run' requested here
  Assignment<ActualDstTypeCleaned,Src,Func>::run(actualDst, src, func);
                                             ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:797:17: note: in instantiation of function template specialization 'Eigen::internal::call_assignment_no_alias<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>, Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>, Eigen::internal::assign_op<Eigen::int_mod<3>, Eigen::int_mod<3>>>' requested here
      internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
                ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:594:7: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::_set_noalias<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      _set_noalias(other);
      ^
/usr/local/include/eigen3/Eigen/src/Core/Matrix.h:423:9: note: in instantiation of function template specialization 'Eigen::PlainObjectBase<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>::PlainObjectBase<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
      : Base(other.derived())
        ^
EigenTest.cpp:82:17: note: in instantiation of function template specialization 'Eigen::Matrix<Eigen::int_mod<3>, 5, 5>::Matrix<Eigen::Inverse<Eigen::Matrix<Eigen::int_mod<3>, 5, 5>>>' requested here
        MatrixMod mi = m.inverse();
                       ^
4 errors generated.

if I change the line

typedef Eigen::Matrix<int_mod<3>, 5, 5> MatrixMod;

to

typedef Eigen::Matrix<int_mod<3>, 4, 4> MatrixMod;

the program compiles just fine and even does exactly what I need it to.

I have no idea what's going on, so if someone could offer some insight, that would be amazing. I'm new to learning Eigen so any advice would be helpful.

Thanks!

I'm trying to perform a calculation using a custom scalar type in Eigen. But the program will not compile for 5x5 matrices and larger. The error code I get is not helpful to me since it is saying abs and < are not defined, which they wouldn't be with the scalars I am working with.

I would like for my program to work, but I would also like to understand what is going on.

Thank you!

0

There are 0 answers