max@0: #include max@0: max@0: #include "armadillo" max@0: max@0: using namespace arma; max@0: using namespace std; max@0: max@0: max@0: int main(int argc, char** argv) max@0: { max@0: cout << "Armadillo version: " << arma_version::as_string() << endl; max@0: max@0: mat A; max@0: max@0: A << 0.165300 << 0.454037 << 0.995795 << 0.124098 << 0.047084 << endr max@0: << 0.688782 << 0.036549 << 0.552848 << 0.937664 << 0.866401 << endr max@0: << 0.348740 << 0.479388 << 0.506228 << 0.145673 << 0.491547 << endr max@0: << 0.148678 << 0.682258 << 0.571154 << 0.874724 << 0.444632 << endr max@0: << 0.245726 << 0.595218 << 0.409327 << 0.367827 << 0.385736 << endr; max@0: max@0: A.print("A ="); max@0: max@0: // determinant max@0: cout << "det(A) = " << det(A) << endl; max@0: max@0: // inverse max@0: cout << "inv(A) = " << endl << inv(A) << endl; max@0: max@0: max@0: // max@0: max@0: double k = 1.23; max@0: max@0: mat B = randu(5,5); max@0: mat C = randu(5,5); max@0: max@0: rowvec r = randu(5); max@0: colvec q = randu(5); max@0: max@0: max@0: // examples of some expressions max@0: // for which optimised implementations exist max@0: max@0: // optimised implementation of a trinary expression max@0: // that results in a scalar max@0: cout << "as_scalar( r*inv(diagmat(B))*q ) = "; max@0: cout << as_scalar( r*inv(diagmat(B))*q ) << endl; max@0: max@0: // example of an expression which is optimised max@0: // as a call to the dgemm() function in BLAS: max@0: cout << "k*trans(B)*C = " << endl << k*trans(B)*C; max@0: max@0: max@0: // If you want to see a trace of how Armadillo max@0: // evaluates expressions, compile with the max@0: // ARMA_EXTRA_DEBUG macro defined. max@0: // This was designed to work with the GCC compiler, max@0: // but it may also work with other compilers max@0: // if you have the Boost libraries installed max@0: // and told Armadillo to use them. max@0: // max@0: // Example for GCC: max@0: // g++ example2.cpp -o example2 -larmadillo -DARMA_EXTRA_DEBUG max@0: // max@0: // Running example2 will now produce a truckload of messages, max@0: // so you may want to redirect the output to a log file. max@0: max@0: return 0; max@0: } max@0: