Index: library/tests/square_mat_stress.cpp
===================================================================
--- library/tests/square_mat_stress.cpp (revision 467)
+++ library/tests/square_mat_stress.cpp (revision 468)
@@ -2,4 +2,5 @@
 #include "../bdm/math/chmat.h"
 #include "base/user_info.h"
+#include "square_mat_point.h"
 #include "UnitTest++.h"
 #include "TestReporterStdout.h"
@@ -19,4 +20,8 @@
 double epsilon = 0.00001;
 bool fast = false;
+
+namespace bdm {
+UIREGISTER(square_mat_point);
+}
 
 namespace UnitTest
@@ -44,9 +49,12 @@
 }
 
+typedef void (*FTestMatrix)(int, square_mat_point *);
+
 template<typename TMatrix>
-void test_matrix(int index, const mat &A) {
+void test_matrix(int index, square_mat_point *point) {
     Real_Timer tt;
 	
-    cout << "agenda[" << index << ']' << endl;
+    cout << "agenda[" << index << "]:" << endl;
+    mat A = point->get_matrix();
     int sz = A.rows();
     CHECK_EQUAL(A.cols(), sz);
@@ -67,6 +75,6 @@
     cout << "to_mat: " << elapsed << " s" << endl;
 
-    vec v = randu(sz);
-    double w = randu();
+    vec v = point->get_vector();
+    double w = point->get_scalar();
     TMatrix sqmat2 = sqmat;
 	
@@ -88,6 +96,7 @@
     elapsed = tt.toc();
 
-    if (!fast) {
-        mat invA = inv(A);
+    mat invA;
+    if (!fast) {
+        invA = inv(A);
 	CHECK_CLOSE(invA, invmat.to_mat(), epsilon);
     }
@@ -105,33 +114,96 @@
 
     cout << "logdet: " << elapsed << " s" << endl;
-}
-
-template<typename TMatrix>
-void test_agenda() {
+
+    tt.tic();
+    double q = sqmat.qform(ones(sz));
+    elapsed = tt.toc();
+
+    if (!fast) {
+        CHECK_CLOSE(sumsum(A), q, epsilon);
+    }
+
+    cout << "qform(1): " << elapsed << " s" << endl;
+
+    tt.tic();
+    q = sqmat.qform(v);
+    elapsed = tt.toc();
+
+    if (!fast) {
+        double r = (A * v) * v;
+        CHECK_CLOSE(r, q, epsilon);
+    }
+
+    cout << "qform(v): " << elapsed << " s" << endl;
+
+    tt.tic();
+    q = sqmat.invqform(v);
+    elapsed = tt.toc();
+
+    if (!fast) {
+        double r = (invA * v) * v;
+	CHECK_CLOSE(r, q, epsilon);
+    }
+
+    cout << "invqform: " << elapsed << " s" << endl;
+
+    TMatrix twice = sqmat;
+
+    tt.tic();
+    twice += sqmat;
+    elapsed = tt.toc();
+
+    if (!fast) {
+        res = 2 * A;
+	CHECK_CLOSE(res, twice.to_mat(), epsilon);
+    }
+
+    cout << "+=: " << elapsed << " s" << endl;
+
+    sqmat2 = sqmat;
+
+    tt.tic();
+    sqmat2.mult_sym(A);
+    elapsed = tt.toc();
+
+    if (!fast) {
+        res = (A * A) * A.T();
+	CHECK_CLOSE(res, sqmat2.to_mat(), epsilon);
+    }
+
+    cout << "^2: " << elapsed << " s" << endl;
+}
+
+void test_agenda(FTestMatrix test) {
     UIFile fag(agenda_file_name);
-    Array<mat> mag;
+    Array<square_mat_point *> mag;
     UI::get(mag, fag, "agenda");
     int sz = mag.size();
     CHECK(sz > 0);
     for (int i = 0; i < sz; ++i) {
-        test_matrix<TMatrix>(i, mag(i));
+        test(i, mag(i));
+    }
+
+    for (int i = 0; i < sz; ++i) {
+        square_mat_point *p = mag(i);
+	mag(i) = 0;
+	delete p;
     }
 }
 
 SUITE(ldmat) {
-    TEST(cycle) {
-        test_agenda<ldmat>();
+    TEST(agenda) {
+        test_agenda(test_matrix<ldmat>);
     }
 }
 
 SUITE(fsqmat) {
-    TEST(cycle) {
-        test_agenda<fsqmat>();
+    TEST(agenda) {
+        test_agenda(test_matrix<fsqmat>);
     }
 }
 
 SUITE(chmat) {
-    TEST(cycle) {
-        test_agenda<chmat>();
+    TEST(agenda) {
+        test_agenda(test_matrix<chmat>);
     }
 }
@@ -159,5 +231,7 @@
 	    update_next = 0;
 	} else {
-	    if (!strcmp(*param, "-c")) {
+	    if (!strcmp(*param, "-a")) {
+	        update_next = 3;
+	    } else if (!strcmp(*param, "-c")) {
 	        update_next = 1;
 	    } else if (!strcmp(*param, "-e")) {
@@ -174,5 +248,5 @@
 
     if (unknown || update_next) {
-        cerr << "usage: " << argv[0] << " [ -f ] [ -e epsilon ] [ -c class ]" << endl;
+        cerr << "usage: " << argv[0] << " [ -f ] [ -e epsilon ] [ -a agenda_input.cfg ] [ -c class ]" << endl;
     } else {
 	UnitTest::TestReporterStdout reporter;
