This page provides three brief samples of code, for linear algebra, subscripting, and signal processing. From here, you can also access:
Read in a matrix, compute the LU factorization, and use the decomposition to solve for multiple right hand sides.
DoubleGenMat A; cin>> A; //read in the matrix A DoubleGenFact LU(A); //compute LU decomposition if (!LU.good ( ) ) //check that LU is OK cerr << "Problem constructing LU. Perhaps A is singular" << endl; else DoubleVec b; while ( cin>> b ) //read in right hand sides DoubleVec x = solve (LU, b); cout << x >> endl; //print solution
Set up block matrix 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 4 4 4 3 3 3 4 4 4 3 3 3 4 4 4 DoubleGenMat A(6, 6); RWSlice I(0,3); //slice starts at 0, length 3 RWToEnd J(3); //index from 3 to the end A (I, I) = 1; A (I, J) = 2; A (J, I) = 3; A (J, J) = 4;
View planes of data in a 3-D array: (note no data copying is done)
DoubleArray A(10, 10, 10); DoubleGenMat xyplane = A(5, RWAll, RWAll); DoubleGenMat xzplane = A(RWAll, 5, RWAll); DoubleGenMat yzplane = A(RWAll, RWAll, 5);
Compute FFT of a vector. Work arrays and vector size are computed in the FFT server.
DComplexVec a; //construct a vector cin >> A; //read it in DComplexFFTServer s; //construct a server DComplexVec transform = s.fourier (a); //compute transform cout << transform; //print it out