Thread: How to define a matrix with each element a fixed size vector?

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    33

    How to define a matrix with each element a fixed size vector?

    Hi, how could I define a boost::ublas::matrix with each element a fixed size vector?

    I try to define it by
    Code:
    matrix< vector<double, 3> > double_matrix ;
    but get the following error:
    Code:
    main.cpp:18: error: template argument 1 is invalid
    main.cpp:18: error: template argument 3 is invalid
    main.cpp:18: error: expected unqualified-id before ‘>’ token
    Actually, the following code doesn't work too, getting the same error:
    Code:
    matrix< vector<double> > double_matrix ;
    So, matrix doesn't support this type of declaration?

    Thanks!

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    >> with each element a fixed size vector?
    If it's fixed size why bother with a vector? Make a struct with three doubles, or a class and overload some operators if you want random access. eg:
    Code:
    #include <boost/numeric/ublas/matrix.hpp>
    
    struct my_doubles {
      double a, b, c;
    };
    
    int main() {
      boost::numeric::ublas::matrix<my_doubles> myd;
    
      return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me with function call
    By NeMewSys in forum C++ Programming
    Replies: 16
    Last Post: 05-22-2008, 01:53 PM
  2. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  3. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  4. Gauss-Jordan Matrix Inversion in C++
    By Max_Power82 in forum C++ Programming
    Replies: 3
    Last Post: 12-03-2006, 08:31 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM