use gmpxx instead of mpfr++
This commit is contained in:
parent
cfd0579a4a
commit
e31c1e72fb
3 changed files with 13 additions and 11 deletions
|
|
@ -9,12 +9,11 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES("~/apps/mpfrc++/")
|
INCLUDE_DIRECTORIES("/usr/include/")
|
||||||
LINK_DIRECTORIES("~/apps/mpfrc++/")
|
|
||||||
LINK_DIRECTORIES("/usr/lib/")
|
LINK_DIRECTORIES("/usr/lib/")
|
||||||
|
|
||||||
ADD_DEFINITIONS( -Wall -W -Wextra )
|
ADD_DEFINITIONS( -Wall -W -Wextra )
|
||||||
|
|
||||||
ADD_EXECUTABLE(test test.cpp)
|
ADD_EXECUTABLE(test test.cpp)
|
||||||
TARGET_LINK_LIBRARIES(test ${Boost_LIBRARIES} gmp mpfr mpreal)
|
TARGET_LINK_LIBRARIES(test ${Boost_LIBRARIES} gmpxx)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,8 @@ public:
|
||||||
inline virtual T L_i_i( const typename Cholesky<T>::CovarMat& V, const unsigned int& i, const T& sum ) const
|
inline virtual T L_i_i( const typename Cholesky<T>::CovarMat& V, const unsigned int& i, const T& sum ) const
|
||||||
{
|
{
|
||||||
/***** ugly hack *****/
|
/***** ugly hack *****/
|
||||||
return sqrt( fabs( V(i,i) - sum) );
|
//return sqrt( fabs( V(i,i) - sum) );
|
||||||
|
return sqrt( abs( V(i,i) - sum) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
16
test.cpp
16
test.cpp
|
|
@ -28,8 +28,7 @@ Authors:
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <mpreal.h>
|
#include <gmpxx.h>
|
||||||
using namespace mpfr;
|
|
||||||
|
|
||||||
#include "cholesky.h"
|
#include "cholesky.h"
|
||||||
|
|
||||||
|
|
@ -115,7 +114,8 @@ T trigsum( const MT& M )
|
||||||
T sum = 0;
|
T sum = 0;
|
||||||
for( unsigned int i=0; i<M.size1(); ++i ) {
|
for( unsigned int i=0; i<M.size1(); ++i ) {
|
||||||
for( unsigned int j=i; j<M.size2(); ++j ) { // triangular browsing
|
for( unsigned int j=i; j<M.size2(); ++j ) { // triangular browsing
|
||||||
sum += fabs( M(i,j) ); // absolute deviation
|
//sum += fabs( M(i,j) ); // absolute deviation
|
||||||
|
sum += abs( M(i,j) ); // absolute deviation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
|
|
@ -168,7 +168,9 @@ void test( unsigned int M, unsigned int N, unsigned int F, unsigned int R, unsig
|
||||||
// a variance-covariance matrix of size N*N
|
// a variance-covariance matrix of size N*N
|
||||||
// Note: a covariance matrix is necessarily semi-positive definite
|
// Note: a covariance matrix is necessarily semi-positive definite
|
||||||
// thus, any failure in the Cholesky factorization is due to round-off errors
|
// thus, any failure in the Cholesky factorization is due to round-off errors
|
||||||
CovarMat V = ublas::prod( ublas::trans(S), S );
|
//CovarMat V = ublas::prod( ublas::trans(S), S );
|
||||||
|
CovarMat ST = ublas::trans(S);
|
||||||
|
CovarMat V = ublas::prod( ST, S );
|
||||||
assert( V.size1() == N && V.size2() == N );
|
assert( V.size1() == N && V.size2() == N );
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( R == 1 ) {
|
if( R == 1 ) {
|
||||||
|
|
@ -252,8 +254,8 @@ int main(int argc, char** argv)
|
||||||
test<long double>(M,N,F,R,seed);
|
test<long double>(M,N,F,R,seed);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::cout << std::endl << "MPREAL 128" << std::endl;
|
std::cout << std::endl << "MPF 128" << std::endl;
|
||||||
mpreal::set_default_prec(128);
|
mpf_set_default_prec(128);
|
||||||
test<mpreal>(M,N,F,R,seed);
|
test<mpf_class>(M,N,F,R,seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue