Tutorial_simple_example_dynamic_size.cpp File Reference
#include <Eigen/Core>
#include <iostream>

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
4  {
5  for (int size = 1; size <= 4; ++size) {
6  Eigen::MatrixXi m(size, size + 1); // a (size)x(size+1)-matrix of int's
7  for (int j = 0; j < m.cols(); ++j) // loop over columns
8  for (int i = 0; i < m.rows(); ++i) // loop over rows
9  m(i, j) = i + j * size; // to access matrix coefficients,
10  // use operator()(int,int)
11  std::cout << m << "\n\n";
12  }
13 
14  Eigen::VectorXf v(4); // a vector of 4 float's
15  // to access vector coefficients, use either operator () or operator []
16  v[0] = 1;
17  v[1] = 2;
18  v(2) = 3;
19  v(3) = 4;
20  std::cout << "\nv:\n" << v << std::endl;
21 }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
int * m
Definition: level2_cplx_impl.h:294
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References i, j, m, size, and v.