[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN benchmark/solve_ax_equals_b.cc internal/op...
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN benchmark/solve_ax_equals_b.cc internal/op... |
Date: |
Fri, 20 Mar 2009 17:21:32 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/03/20 17:21:32
Modified files:
benchmark : solve_ax_equals_b.cc
internal : operators.hh
Log message:
Added full inverse solvers.
Reomoved dependence on CVD for timers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/benchmark/solve_ax_equals_b.cc?cvsroot=toon&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/operators.hh?cvsroot=toon&r1=1.19&r2=1.20
Patches:
Index: benchmark/solve_ax_equals_b.cc
===================================================================
RCS file: /cvsroot/toon/TooN/benchmark/solve_ax_equals_b.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- benchmark/solve_ax_equals_b.cc 20 Mar 2009 16:49:25 -0000 1.1
+++ benchmark/solve_ax_equals_b.cc 20 Mar 2009 17:21:30 -0000 1.2
@@ -1,13 +1,20 @@
#include <TooN/TooN.h>
#include <TooN/LU.h>
+#include <TooN/helpers.h>
#include <TooN/gaussian_elimination.h>
-#include <cvd/timer.h>
#include <tr1/random>
+#include <sys/time.h> //gettimeofday
using namespace TooN;
using namespace std;
using namespace tr1;
-using namespace CVD;
+
+double get_time_of_day()
+{
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ return tv.tv_sec+tv.tv_usec * 1e-6;
+}
std::tr1::mt19937 eng;
std::tr1::uniform_real<double> rnd;
@@ -35,6 +42,7 @@
LU<R> lu(a);
x = lu.get_inverse() * b;
+ //x = lu.backsub(b);
}
static string name()
@@ -43,6 +51,7 @@
}
};
+
struct UseGaussianElimination
{
template<int R, int C> static void solve(const Matrix<R, R>& a, const
Matrix<R, C>& b, Matrix<R, C>& x)
@@ -55,11 +64,25 @@
return "GE";
}
};
+struct UseGaussianEliminationInverse
+{
+ template<int R, int C> static void solve(const Matrix<R, R>& a, const
Matrix<R, C>& b, Matrix<R, C>& x)
+ {
+ Matrix<R> i, inv;
+ Identity(i);
+ inv = gaussian_elimination(a, i);
+ x = inv * b;
+ }
+
+ static string name()
+ {
+ return "GI";
+ }
+};
template<int Size, int Cols, class Solver> void benchmark_ax_eq_b()
{
- cvd_timer t;
- double time=0;
+ double time=0, t_tmp;
double sum=0;
int n=0;
@@ -77,9 +100,9 @@
for(int c=0; c < Cols; c++)
b[r][c] = rnd(eng);
- t.reset();
+ t_tmp = get_time_of_day();
Solver::template solve<Size, Cols>(a, b, x);
- time += t.get_time();
+ time += get_time_of_day() - t_tmp;
for(int r=0; r < Size; r++)
@@ -127,7 +150,7 @@
static void iter()
{
benchmark_iter<Size, Cols, Test>::iter();
- ColIter<Size, Cols-1, Test>::iter();
+ ColIter<Size, Cols-50, Test>::iter();
}
};
@@ -143,8 +166,8 @@
{
static void iter()
{
- ColIter<Size, Size*8+1, Test>::iter();
- SizeIter<Size-1, Test>::iter();
+ ColIter<Size, 500+1, Test>::iter();
+ SizeIter<Size-4, Test>::iter();
}
};
@@ -158,7 +181,7 @@
int main()
{
- SizeIter<5, TypeList<UseGaussianElimination, TypeList<UseLU, Null> >
>::iter();
+ SizeIter<4, TypeList<UseGaussianElimination,
TypeList<UseGaussianEliminationInverse, TypeList<UseLUInv, TypeList<UseLU,
Null> > > > >::iter();
return global_sum != 123456789.0;
}
Index: internal/operators.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/operators.hh,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- internal/operators.hh 10 Mar 2009 16:50:11 -0000 1.19
+++ internal/operators.hh 20 Mar 2009 17:21:31 -0000 1.20
@@ -211,7 +211,6 @@
template<int R1, int C1, int R2, int C2, typename P1, typename P2, typename
B1, typename B2>
Matrix<R1, C2, typename Internal::MultiplyType<P1, P2>::type> operator*(const
Matrix<R1, C1, P1, B1>& m1, const Matrix<R2, C2, P2, B2>& m2)
{
- SizeMismatch<R1, C2>:: test(m1.num_rows(),m2.num_cols());
SizeMismatch<C1, R2>:: test(m1.num_cols(),m2.num_rows());
return Matrix<R1, C2, typename Internal::MultiplyType<P1,
P2>::type>(m1, m2, m1.num_rows(), m2.num_cols(),
Operator<Internal::MatrixMultiply>());
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN benchmark/solve_ax_equals_b.cc internal/op...,
Edward Rosten <=