Default constructor for vector class.
Constructor to create a vector having size nSize.
Constructor to create a vector copy of an Origin Dataset.
Constructor to create a vector from a source column.
Complex vector constructor.
vector( )
vector( UINT nSize )
vector( Dataset & ds, BOOL bRemoveMissingValues = FALSE )
vector( Column & cc, int nLowerIndex = -1, int nUpperIndex = -1, int nWriteback = WRITEBACK_NO )
vector( vector & vR, vector & vI )
EX1
void vector_vector_ex1() { vector vD = {1.0, 2.0, 3.0, 4.0}; // vector of doubles double dTest ; dTest = vD[2]; printf("the dTest value is %f", dTest); }
EX2
void vector_vector_ex2() { vector<string> vS = {"Hello", "World"}; // vector of strings for(int n = 0 ; n<vS.GetSize(); n++) out_str(vS[n]); }
EX3
void vector_vector_ex3() { vector vD(10); //vD is double vector<int> vN(10); //vN is int printf("The double value is\n"); for(int n =0 ; n < vD.GetSize(); n++) { vD[n] = n*12; printf("%.1f\n", vD[n]); } printf("The int value is\n"); for(int m =0 ; m < vN.GetSize(); m++) { vN[m] = m*12; printf("%d\n", vN[m]); } }
EX4
void vector_vector_ex4() { Worksheet wks=Project.ActiveLayer(); if (wks) { Dataset dsB(wks,1); dsB.SetSize(5); // Set sizeof data set to 5 dsB[0]=-1; dsB[1]=5; dsB[2]=NANUM; // Missing value will be removed dsB[3]=NANUM; // Missing value will be removed dsB[4]=23; vector vB( dsB, TRUE ); // Copy Dataset dsD to vector vD removing missing values printf("The size of vB is %d", vB.GetSize()); // Elements dsB[2] and dsB[3] are removed } }
EX5
// Have some data in the second column of the current worksheet before running this example. int vector_vector_ex5() { Worksheet wks=Project.ActiveLayer(); Column col(wks, 1); vector v(col, 2, 5, WRITEBACK_DELETE_ON_SHRINK | WRITEBACK_INSERT_ON_EXPAND); // Dump the source range int nSrcLowerIndex, nSrcUpperIndex; if ( v.GetSourceRange ( nSrcLowerIndex, nSrcUpperIndex )) printf("nSrcLowerIndex = %ld\tnSrcUpperIndex = %ld\n", nSrcLowerIndex, nSrcUpperIndex); // Modify the vector: int nNewVectorSize = 80; v.SetSize(nNewVectorSize); for (int ii = 0; ii < nNewVectorSize; ii++) { v[ii] = 100 * (ii + 1); printf ("%.1f\n", v[ii]) } return 0; }
EX6
void vector_vector_ex6() { vector vR = { 1, 2, 3 }; vector vI = { 4, 5, 6 }; vector<complex> vComplex(vR, vI); for(int ii = 0; ii < vComplex.GetSize(); ++ii) { out_complex("", vComplex[ii]); } /* Output: 1.000000+4.000000i 2.000000+5.000000i 3.000000+6.000000i */ }
For the constructor to create a complex vector from two vectors - one containing the Real parts the other containing the Imaginary parts. The input vectors must have a base type of double and must have the same number of elements.
origin.h