c++ - How to convert column vector into MxN matrix? -
I am relatively new to C ++ and how to get trapped in this problem. I have 999x1 of point coordinates Vector and I want to convert it to 333x3 matrix. Besides, I am using various CPP files for a project, so that the number of points that the sets reads is that the function is in a different file. How can I make this matrix and how should I use it in my main code? I took the The vector is actually a container for just one array. So basically you have a Or declare a matrix (either assign a static or dynamic memory for it) and copy all the elements of the matrix: Choose the method you want - the first advantage is that it does not have extra memory vector & lt; Vector & lt; Float & gt; & Gt; Macatrix thing but you need to specify rows and columns in this type of definition, as long as I can not read the file. If I try to declare the matrix variable above the function which is reading the pocket file, its scope is limited and I can not use the matrix in the main CPP. It's hard to write code because it has many links with other files, I hope you have my problem! Please help me on this issue ... thanks in advance!
int A [99 9] and want to convert it to
int m [333] [3] ; Keeping in mind that both 1D and 2D arrays in memory are stored in a stored memory area, you can get it in many ways:
- An indicator and two indexed I, j: use 3 elements are your first line, next 3 elements your second line and so on. Int vector & lt; Int & gt; V; Int * p, I = 0, j = 0; //i = [0..332], j = [0..2] P = & amp; V [0]; * (P + (i * 3) + J); // it is similar to p [i] [j];
int m [333 ] [3]; // I for this example with a constant allocation (i = 0; i
Comments
Post a Comment