Copy array to matrix column

 

Is there a built in fast function ?

heres what i'm doing so far 

  double array[]={1.1,2.2,3.3,4.4,5.5};
  double array2[]={6.6,7.7,8.8,9.9,0.0};
  matrix M;
  vector copier;
  M.Init(5,2);
  copier.Assign(array);
  M.Col(copier,0);
  copier.Assign(array2);
  M.Col(copier,1);
  Print(M);

Suppose each column is a sample and the rows are features and i can't do 

matrix M={array,array2};

because i'd have to write 16000 arrays by hand :)

edit :: (could be a separate thread)

Also when using this 

vector matrix::Col(
  const ulong   ncol      // column number
   );

i.e. having a matrix M and wanting to pass only one column to a function which receives a vector 

void predict(vector &inputs){

}

Are you creating a copy of the vector or are you reading straight from the matrix ?

I mean would it be faster accessing the matrix directly and passing the entire matrix ? (like so)

void predict(matrix &matrix_with_inputs,ulong read_from_column){
}

Assume gigantic amounts of data here not 5x5s

Also fix your editor , if i add a code snippet at the bottom i cannot create a new line after it 

 
Lorentzos Roussos:

Is there a built in fast function ?

heres what i'm doing so far 

Suppose each column is a sample and the rows are features and i can't do 

because i'd have to write 16000 arrays by hand :)

Your issue is not clear. Why do you want arrays to fill a vector to fill a matrix ?!

Assign method allow you to push an array directly in a matrix.