Skip to content
Snippets Groups Projects
Commit 6a32d1b7 authored by Mark Woolrich's avatar Mark Woolrich
Browse files

*** empty log message ***

parent ec25734a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
......
......@@ -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,
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment