double[][] m = new double[7][2];
System.out.println(m.length);
System.out.println(m[0].length);
or a simple matrix class.
void qrdec(matrix* A, matrix* R) that
performs in-place Gram-Schmidt orthogonalization of matrix A (that is, A
turns into Q) and
fills-in the matrix R.
void qrbak(matrix* Q, matrix* R, vector* b,
vector* result)
which solves the equation QRx=b by back-substitution and
puts the result in vector result.
double absdet(matrix* R) which
calculates the absolute value of the determinant.
void inverse(matrix* Q, matrix* R, matrix* AI)
which calculates the inverse into matrix AI.
QR with member variables matrix Q,
R; and the constructor QR(matrix& A) which first copies
A into Q and then performs the in-place orthogonalization.
The functions from the procedurial style become member functions
void qrbak(vector& b, vector& result)
double absdet()
void inverse(matrix& AI)
(6 points) Gram-Schmidt orthogonalization
main function which applies the implemented
functions on some matrices and checks that everything works as intended.
(3 points) Given's rotation
Do the same, but this time use Given's rotation algorithm instead of Gram-Schmidt algorithm.
Devise a smart method of storing the Q-matrix: do not actually calculate and store the Q-matrix but rather store the rotation θ-angles in the places of the corresponding zeroed elements of matrix A. The backsubstitution routine should not build the Q-matrix either but rather apply (smartly) the stored individual Given's rotations. This should save you a whole matrix to store as compared to your first exercise.
Compare the speeds of these two implementations.
Implement LU-decomposition (with or without partial pivoting), back-substitution, and inverse.
Or, at your choice, Cholesky-decomposition using Cholesky-Banachiewicz or Cholesky-Crout algorithms.
Hint: the total number of CPU-seconds used by a program
my_prog can be determined by the POSIX time
utility.
The command
\time --format "%U" --append --output=time.txt ./my_prog > /dev/null
or, in short
\time -f "%U" -ao time.txt ./my_prog > /dev/null
runs the program (disregarding the standard output) and appends the
number of consumed CPU-seconds to the file time.txt.
Without the --append option (or, in short, -a)
the file time.txt gets overwritten. Backslash here is
needed to run the actual utility rather than built-in bash command (with
similar possibilities, actually).
An example of the usage of time can be found here (see the
makefile).
Implement a garbage-collected version of the vector/matrix library and
compare the memory consumption of the garbage-collect vs. malloc'ed versions. The garbage collector
is installed in the proper place on molveno and in
/usr/users/fedorov/include,
/usr/users/fedorov/lib
on lifa.