STK++ 0.9.13
|
This page explains how to create reference on existing arrays.
Any slice of an existing array can be referenced by an other array and modified using this "reference" container.
Example | Output |
---|---|
#include "STKpp.h"
using namespace STK;
{
ArraySquareX a(4); a << 1.,2.,3.,4.
, 1.,2.,3.,4.
, 1.,1.,1.,1.
, 1.,1.,1.,1.;
// create a reference
b = -1.;
std::cout << "Modified a=\n" << a << "\n";
, 1.,2.,3.,4.
, 1.,1.,1.,1.;
// create a reference
d = -1.;
std::cout << "Modified c=\n" << c;
return 0;
}
This file include all the header files of the STK++ project. The MultidimRegression class allows to regress a multidimensional output variable among a multivariat... Definition STK_MultidimRegression.h:52 Index sub-vector region: Specialization when the size is unknown. Definition STK_Range.h:265 The namespace STK is the main domain space of the Statistical ToolKit project. | Modified a= -1 -1 -1 4 -1 -1 -1 4 1 1 1 1 1 1 1 1 Modified c= 1 -1 3 4 1 -1 3 4 1 -1 1 1 |
This method allow to get a safe access to some sub-part of a big array that you want to modify.
It is possible to map a single pointer Type* or a double pointer Type** in respectively CArrays and Array2Ds using the constructors.
Wrapper Constructors | Examples |
---|---|
Wrap the data pointed by q in an Array with rows in the range I and columns in the range J. Array2D<Type>( Type** q, Range const& I, Range const& J);
| In this example we create an array of size (10, 5) and wrap it in an Array2. Real** q = new Real*[10];
for (int j=0; j<10; j++) { q[j] = new Real[5];}
//wrap q. Note that q will not be freed when a is deleted
Array2D<Real> a(q, Range(0,10), Range(0,5)); //
|
Wrapper constructor. Wrap the data pointed by q in an Array with rows and columns of size m and n. CArray<Type>( Type* q, int m, int n);
| In this example we create an array of size (10, 5) and wrap it in an Array2D. Real* q = new Real[10];
for (int j=0; j<10; j++) { q[j] = j;}
//wrap q in a fixed size array of size (2,5).
// Note that q will not be freed when a is deleted
CArray<Real, 2, 5> a(q, 2, 5);
|