From 6a32d1b72f0c935aa7733bd08721af8405e92d44 Mon Sep 17 00:00:00 2001 From: Mark Woolrich <woolrich@fmrib.ox.ac.uk> Date: Thu, 4 Aug 2005 15:18:31 +0000 Subject: [PATCH] *** empty log message *** --- Makefile | 2 +- quick.cc | 31 ++++++++----------------------- t2z.cc | 15 +++++++++++++++ t2z.h | 28 ++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 7bdc4a4..413a4a3 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ USRLDFLAGS = -L${LIB_NEWMAT} -L${LIB_PROB} -L${LIB_ZLIB} OBJS = miscmaths.o optimise.o miscprob.o kernel.o histogram.o base2z.o t2z.o f2z.o volume.o volumeseries.o minimize.o cspline.o sparse_matrix.o sparsefn.o rungekutta.o #OBJS = miscmaths.o optimise.o miscprob.o kernel.o histogram.o base2z.o t2z.o f2z.o volume.o volumeseries.o minimize.o cspline.o -LIBS = -lutils -lnewmat -lprob -lm +LIBS = -lutils -lfslio -lniftiio -lznz -lz -lnewmat -lprob -lm # The target "all" should ALWAYS be provided # typically it will just be another target name diff --git a/quick.cc b/quick.cc index 940cde6..9eacfca 100644 --- a/quick.cc +++ b/quick.cc @@ -14,37 +14,22 @@ #define WANT_MATH #include "miscmaths.h" -#include "sparse_matrix.h" -#include "libprob.h" +#include "t2z.h" +//#include "libprob.h" using namespace MISCMATHS; int main(int argc, char *argv[]) { try{ - - SparseMatrix x(3,4); - SparseMatrix y(3,4); - x.insert(1,1,1); - y.insert(1,1,2); - y.insert(1,2,3); + + float tmp = atof(argv[1]); + int tmp2 = atoi(argv[2]); - x.insert(2,3,1.5); + OUT(tmp); + OUT(tmp2); - y.insert(2,4,3); - x.insert(2,4,-1); - - y.insert(3,4,6); - - SparseMatrix ret; - - - OUT(x.AsMatrix()); - OUT(y.AsMatrix()); - - add(x,y,ret); - - OUT(ret.AsMatrix()); + OUT(Z2t::getInstance().convert(tmp,tmp2)); } catch(Exception p_excp) diff --git a/t2z.cc b/t2z.cc index 4382744..4df56bf 100644 --- a/t2z.cc +++ b/t2z.cc @@ -18,7 +18,22 @@ using namespace Utilities; namespace MISCMATHS { T2z* T2z::t2z = NULL; + Z2t* Z2t::z2t = NULL; + float Z2t::convert(float z, int dof) + { + float t = 0.0; + + if(z>8) + throw Exception("z is too large to convert to t"); + + double p = MISCMATHS::ndtr(z); + cerr << "p = " << p << endl; + t = MISCMATHS::stdtri(dof,p); + + return t; + } + float T2z::larget2logp(float t, int dof) { // static float logbeta[] = { 1.144729885849, 0.693147180560, diff --git a/t2z.h b/t2z.h index dbcd985..df1ca10 100644 --- a/t2z.h +++ b/t2z.h @@ -54,6 +54,34 @@ namespace MISCMATHS { return *t2z; } + + + class Z2t + { + public: + static Z2t& getInstance(); + ~Z2t() { delete z2t; } + + float convert(float t, int dof); + + private: + Z2t() + {} + + const Z2t& operator=(Z2t&); + Z2t(Z2t&); + + static Z2t* z2t; + + }; + + inline Z2t& Z2t::getInstance(){ + if(z2t == NULL) + z2t = new Z2t(); + + return *z2t; + } + } #endif -- GitLab