[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NDArrays in octave API with dimension greater than 3: follow up
From: |
John Weatherwax |
Subject: |
NDArrays in octave API with dimension greater than 3: follow up |
Date: |
Sun, 19 Mar 2006 18:40:06 -0600 |
Hello,
I think I have found a solution to my own problem, I construct a 4
dimensional array as follows:
// u T(otal) solution is declared as an "NDArray":
dim_vector dv(NPDE,NX,NY); // dimension of each solution page
dim_vector dvd(ntouts); // dimension of the number of pages
dv.concat(dvd);
NDArray uT( dv );
Array<int> dim(4,0);
// u T(ime) S(tep) solution:
Matrix uTS( NPDE, NX, NY );
for (int i = 0; i < nr_results; i++) {
// generate a uTS 3D array ... created with the code I "wrote"
// not shown ...
// append the matrix
dim(3) = i;
uT = uT.concat(uTS, dim);
}
Thanks to any that responded,
John Weatherwax (Wax)
c------------------------------------------------------------------------
c Old letter follows:
c------------------------------------------------------------------------
I have been successful in using/working with NDArrays of *3*
dimensions in the C++ octave API before but now I need to create and
manipulate a *4* dimensional array. The code I had used before solved
a problem and generated a "page" of data which I then concatenated
onto the created array. The code I used (provide with much thanks, by
Stefan van der Walt) is essentially the following:
int nr_results = 10;
int rows = 5;
int cols = 5;
NDArray nda(dim_vector(rows, cols, nr_results));
Array<int> dim(3,0);
for (int i = 0; i < nr_results; i++) {
// generate a matrix ... created with the code I "wrote"
Matrix A(rows, cols, 0);
A(0,0) = i;
// append the matrix
dim(2) = i;
nda = nda.concat(A, dim);
}
Not "super" familiar with the API I'm not sure how to generalize the
dim_vector call to create a 4 dimensional array along with any other
unseen gotchas. I still basically need to do the same thing but now
the code I "wrote" generates a three dimensional matrix/array and I
concatenate along the last dimension again.
Any help would be greatly appreciated.
TIA,
John (WAX) Weatherwax
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- NDArrays in octave API with dimension greater than 3: follow up,
John Weatherwax <=