STK++ 0.9.13
tutoAddingCols.cpp
Go to the documentation of this file.
1#include "STKpp.h"
2using namespace STK;
3int main(int argc, char *argv[])
4{
5 ArrayXX A(4, Range(0,2));
6 Law::Normal law(1.,2.);
7 A.rand(law);
8 stk_cout << _T("A =\n") << A;
9 // Adding a column with value 5
11 // insert an uninitialized columns at place 2
12 A.insertCols(2, 2);
13 // set x^2 and x^3 with x in columns 1
14 A.col(2) = A.col(1).square();
15 A.col(3) = A.col(1).cube();
16 // add an uninitialized columns at the end
17 A.pushBackCols(1);
18 // set x^2 with x in columns 4
19 A.col(5) = A.col(4).square();
20 stk_cout << _T("A =\n") << A;
21 // do the same with a vector
22 VectorX B(4); B << 1, 3, 5, 6;
23 stk_cout << _T("B = ") << B.transpose();
24 // insert 1 uninitialized element in place 2
25 B.insertElt(2); B[2] = 3; // set value to 3
26 stk_cout << _T("B = ") << B.transpose();
27}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
This file include all the header files of the STK++ project.
void insertElt(int pos, int const &n=1)
Insert n elements at the position pos of the container.
TransposeOperator< Derived > const transpose() const
Derived & rand(Law::IUnivLaw< Type > const &law)
set random values to this using a distribution law given by the user.
Define the constant point.
void pushFrontCols(int n=1)
Insert n columns at the beginning of the array.
void insertCols(int pos, int n=1)
Insert n columns at the index pos to the array.
void pushBackCols(int n=1)
Add n columns at the end of the array.
Col col(int j) const
access to a part of a column.
Normal distribution law.
The namespace STK is the main domain space of the Statistical ToolKit project.
TRange< UnknownSize > Range
Definition STK_Range.h:59
int main(int argc, char *argv[])