diff --git a/Makefile b/Makefile index 7bdc4a4672c81648abeb04a7709273a332431c4f..413a4a3261d85000891590bdf86ca962a5177052 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 940cde65b417be629697dd897f3761eca161e1f8..9eacfca663072d75b446f92f675a579e247ff314 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 43827449a0a72803c1bb687d9954e3a1249adad8..4df56bf7b33d309a8c04c7e15799f37c4e4da1f6 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 dbcd9852728a2f4ccce6bf5cf2e422f0b7e1fa95..df1ca1063501824aaaeeac3290b856ec4de14797 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