Compare commits

..

3 commits

Author SHA1 Message Date
nojhan
cfd0579a4a typedef AtomType, in case it would be useful 2012-01-29 18:19:07 +01:00
nojhan
9725d5efd1 build with cmake 2012-01-29 18:18:28 +01:00
nojhan
1475e2a743 templatize everything to work with non-standard types like mpreal (of the mpfrc++ library) 2012-01-29 11:26:25 +01:00
3 changed files with 21 additions and 5 deletions

View file

@ -9,8 +9,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
INCLUDE_DIRECTORIES("~/apps/mpfrc++/")
LINK_DIRECTORIES("~/apps/mpfrc++/")
LINK_DIRECTORIES("/usr/lib/")
ADD_DEFINITIONS( -Wall -W -Wextra )
ADD_EXECUTABLE(test test.cpp)
TARGET_LINK_LIBRARIES(test ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(test ${Boost_LIBRARIES} gmp mpfr mpreal)

View file

@ -55,6 +55,9 @@ public:
// FIXME check if triangular types behaviour is like having 0
typedef ublas::matrix< T > FactorMat;
//! The type of the scalars
typedef T AtomType;
/** Instanciate without computing anything, you are responsible of
* calling the algorithm and getting the result with operator()
* */
@ -322,8 +325,8 @@ public:
T sum = 0.0;
// for( unsigned int k=1; k<i-1; ++k) {
// for( unsigned int k=1; k<i; ++k) {
for( unsigned int k=0; k<i; ++k) {
// for( unsigned int k=0; k<i-1; ++k) {
// for( unsigned int k=0; k<i; ++k) {
for( unsigned int k=0; k<i-1; ++k) {
sum += this->_L(i, k) * this->_L(i, k);
}
this->_L(i,i) = this->_L(i,i) - sum;
@ -338,8 +341,8 @@ public:
sum = 0.0;
// for( unsigned int k = 1; k < i-1; ++k ) {
// for( unsigned int k = 1; k < i; ++k ) {
for( unsigned int k = 0; k < i; ++k ) {
// for( unsigned int k = 0; k < i-1; ++k ) {
// for( unsigned int k = 0; k < i; ++k ) {
for( unsigned int k = 0; k < i-1; ++k ) {
sum += this->_L(j, k) * this->_L(i, k);
}
this->_L(j,i) = this->_L(j,i) - sum;

View file

@ -28,6 +28,9 @@ Authors:
#include <map>
#include <vector>
#include <mpreal.h>
using namespace mpfr;
#include "cholesky.h"
@ -238,6 +241,7 @@ int main(int argc, char** argv)
std::clog << "Legend:" << std::endl;
std::clog << "\tAlgo: (failures/runs)\tAverage error" << std::endl;
/*
std::cout << std::endl << "FLOAT" << std::endl;
test<float>(M,N,F,R,seed);
@ -246,5 +250,10 @@ int main(int argc, char** argv)
std::cout << std::endl << "LONG DOUBLE" << std::endl;
test<long double>(M,N,F,R,seed);
*/
std::cout << std::endl << "MPREAL 128" << std::endl;
mpreal::set_default_prec(128);
test<mpreal>(M,N,F,R,seed);
}