home *** CD-ROM | disk | FTP | other *** search
- #include <stack.h>
- #include <osfcn.h>
-
- // Push the CTM onto the stack; return success
- int MatrixStack::push() {
- if (depth < MatrixStackDepth) {
- stack[depth++] = tos;
- adjointflag = 0; // Adjoint not computed
- return 1;
- } else {
- cerr << "MatrixStack::push(): stack full!" << endl;
- return 0;
- }
- }
-
- // Pop the stack into the CTM; return success
- int MatrixStack::pop() {
- if (depth > 0) {
- tos = stack[--depth];
- adjointflag = 0; // Adjoint lost and needs to be recomputed
- return 1;
- } else {
- cerr << "MatrixStack::pop(): stack empty!" << endl;
- return 0;
- }
- }
-
- // Compute the adjoint & determinant of the CTM
- void MatrixStack::compute_adjoint() {
- tosadjoint = adjoint(tos, &tosdeterminant);
- adjointflag = 1;
- }
-
- // Returns the adjoint of the CTM
- HMatrix &MatrixStack::ctmadjoint() {
- if (!adjointflag)
- compute_adjoint();
- return tosadjoint;
- }
-
- // Returns the determinant of the CTM
- float MatrixStack::ctmdet() {
- if (!adjointflag)
- compute_adjoint();
- return tosdeterminant;
- }
-