Skip to content
Snippets Groups Projects
Commit bc791e27 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Remove all "using namespace" statements from headers

parent 7c952ed9
No related branches found
No related tags found
1 merge request!8Mnt/conda
......@@ -21,16 +21,16 @@
#define WANT_STREAM
#define WANT_MATH
using namespace NEWMAT;
using namespace std;
///////////////////////////////////////////////////////
namespace MISCMATHS {
class Cspline{
public:
Cspline(){}
Cspline(ColumnVector& pnodes,ColumnVector& pvals):
Cspline(NEWMAT::ColumnVector& pnodes,NEWMAT::ColumnVector& pvals):
nodes(pnodes),
vals(pvals),
n(nodes.Nrows())
......@@ -39,7 +39,7 @@ namespace MISCMATHS {
fitted=true;
}
Cspline(ColumnVector& pnodes, Matrix& pcoefs) :
Cspline(NEWMAT::ColumnVector& pnodes, NEWMAT::Matrix& pcoefs) :
nodes(pnodes),
coefs(pcoefs),
n(nodes.Nrows())
......@@ -49,23 +49,23 @@ namespace MISCMATHS {
fitted=false;
};
void set(ColumnVector& pnodes,ColumnVector& pvals);
void set(ColumnVector& pnodes, Matrix& pcoefs);
void set(NEWMAT::ColumnVector& pnodes,NEWMAT::ColumnVector& pvals);
void set(NEWMAT::ColumnVector& pnodes, NEWMAT::Matrix& pcoefs);
void fit();
float interpolate(float xx) const;
float interpolate(float xx,int ind) const;
ColumnVector interpolate(const ColumnVector& x) const;
ColumnVector interpolate(const ColumnVector& x, const ColumnVector& indvec) const;
NEWMAT::ColumnVector interpolate(const NEWMAT::ColumnVector& x) const;
NEWMAT::ColumnVector interpolate(const NEWMAT::ColumnVector& x, const NEWMAT::ColumnVector& indvec) const;
protected:
bool fitted;
ColumnVector nodes;
ColumnVector vals;
Matrix coefs;
NEWMAT::ColumnVector nodes;
NEWMAT::ColumnVector vals;
NEWMAT::Matrix coefs;
int n;
void diff(const ColumnVector& x, ColumnVector& dx );
void diff(const NEWMAT::ColumnVector& x, NEWMAT::ColumnVector& dx );
};
}
......
......@@ -14,9 +14,7 @@
#include "armawrap/newmatap.h"
#include "armawrap/newmatio.h"
#include "base2z.h"
//#include "miscmaths.h"
using namespace NEWMAT;
namespace MISCMATHS {
......@@ -28,9 +26,9 @@ namespace MISCMATHS {
float convert(float f, int d1, int d2);
static void ComputeFStats(const ColumnVector& p_fs, int p_dof1, int p_dof2, ColumnVector& p_zs);
static void ComputeFStats(const ColumnVector& p_fs, int p_dof1, const ColumnVector& p_dof2, ColumnVector& p_zs);
static void ComputeFStats(const ColumnVector& p_fs, const ColumnVector& p_dof1, const ColumnVector& p_dof2, ColumnVector& p_zs);
static void ComputeFStats(const NEWMAT::ColumnVector& p_fs, int p_dof1, int p_dof2, NEWMAT::ColumnVector& p_zs);
static void ComputeFStats(const NEWMAT::ColumnVector& p_fs, int p_dof1, const NEWMAT::ColumnVector& p_dof2, NEWMAT::ColumnVector& p_zs);
static void ComputeFStats(const NEWMAT::ColumnVector& p_fs, const NEWMAT::ColumnVector& p_dof1, const NEWMAT::ColumnVector& p_dof2, NEWMAT::ColumnVector& p_zs);
private:
F2z() : Base2z()
......
......@@ -18,8 +18,6 @@
#include "armawrap/newmatio.h"
#include "miscmaths.h"
using namespace NEWMAT;
namespace MISCMATHS {
class Histogram
......@@ -33,35 +31,35 @@ namespace MISCMATHS {
Histogram(const Histogram& in){ *this=in;}
Histogram(const ColumnVector& psourceData, int numBins)
Histogram(const NEWMAT::ColumnVector& psourceData, int numBins)
: sourceData(psourceData), calcRange(true), bins(numBins){}
Histogram(const ColumnVector& psourceData, float phistMin, float phistMax, int numBins)
Histogram(const NEWMAT::ColumnVector& psourceData, float phistMin, float phistMax, int numBins)
: sourceData(psourceData), calcRange(false), histMin(phistMin), histMax(phistMax), bins(numBins){}
void set(const ColumnVector& psourceData, int numBins) {
void set(const NEWMAT::ColumnVector& psourceData, int numBins) {
sourceData=psourceData; calcRange=true; bins=numBins;
}
void set(const ColumnVector& psourceData, float phistMin, float phistMax, int numBins) {
void set(const NEWMAT::ColumnVector& psourceData, float phistMin, float phistMax, int numBins) {
sourceData=psourceData; calcRange=false; histMin=phistMin; histMax=phistMax; bins=numBins;
}
void generate();
void generate(ColumnVector exclusion_values);
ColumnVector generateCDF();
void generate(NEWMAT::ColumnVector exclusion_values);
NEWMAT::ColumnVector generateCDF();
float getHistMin() const {return histMin;}
float getHistMax() const {return histMax;}
void setHistMax(float phistMax) {histMax = phistMax;}
void setHistMin(float phistMin) {histMin = phistMin;}
void setexclusion(ColumnVector exclusion_values) {exclusion =exclusion_values;}
void setexclusion(NEWMAT::ColumnVector exclusion_values) {exclusion =exclusion_values;}
void smooth();
int integrateAll() {return sourceData.Nrows();}
const ColumnVector& getData() {return histogram;}
void setData(const ColumnVector& phist) { histogram=phist;}
const NEWMAT::ColumnVector& getData() {return histogram;}
void setData(const NEWMAT::ColumnVector& phist) { histogram=phist;}
int integrateToInf(float value) const { return integrate(value, histMax); }
int integrateFromInf(float value) const { return integrate(histMin, value); }
......@@ -76,16 +74,16 @@ namespace MISCMATHS {
float getPercentile(float perc);
inline int getNumBins() const {return bins;}
inline ColumnVector getCDF() const {return CDF;}
inline ColumnVector getsourceData()const {return sourceData;}
inline NEWMAT::ColumnVector getCDF() const {return CDF;}
inline NEWMAT::ColumnVector getsourceData()const {return sourceData;}
protected:
private:
ColumnVector sourceData;
ColumnVector histogram;
ColumnVector exclusion;
ColumnVector CDF;
NEWMAT::ColumnVector sourceData;
NEWMAT::ColumnVector histogram;
NEWMAT::ColumnVector exclusion;
NEWMAT::ColumnVector CDF;
bool calcRange;
......@@ -107,7 +105,7 @@ namespace MISCMATHS {
return (bin*(histMax-histMin))/(float)bins + histMin;
}
inline ColumnVector Histogram::generateCDF()
inline NEWMAT::ColumnVector Histogram::generateCDF()
{
......
......@@ -17,8 +17,6 @@
#include <cmath>
#include "armawrap/newmat.h"
using namespace NEWMAT;
using namespace std;
namespace MISCMATHS {
......@@ -33,9 +31,9 @@ namespace MISCMATHS {
int p_widthx;
int p_widthy;
int p_widthz;
ColumnVector p_kernelx;
ColumnVector p_kernely;
ColumnVector p_kernelz;
NEWMAT::ColumnVector p_kernelx;
NEWMAT::ColumnVector p_kernely;
NEWMAT::ColumnVector p_kernelz;
// stop all forms of creation except the constructors below
kernelstorage();
......@@ -48,8 +46,8 @@ namespace MISCMATHS {
float *storey;
float *storez;
kernelstorage(const ColumnVector& kx, const ColumnVector& ky,
const ColumnVector& kz, int wx, int wy, int wz)
kernelstorage(const NEWMAT::ColumnVector& kx, const NEWMAT::ColumnVector& ky,
const NEWMAT::ColumnVector& kz, int wx, int wy, int wz)
{
p_kernelx = kx; p_kernely = ky; p_kernelz = kz;
p_widthx = wx; p_widthy = wy; p_widthz = wz;
......@@ -92,9 +90,9 @@ namespace MISCMATHS {
int widthx() const { return p_widthx; }
int widthy() const { return p_widthy; }
int widthz() const { return p_widthz; }
const ColumnVector& kernelx() const { return p_kernelx; }
const ColumnVector& kernely() const { return p_kernely; }
const ColumnVector& kernelz() const { return p_kernelz; }
const NEWMAT::ColumnVector& kernelx() const { return p_kernelx; }
const NEWMAT::ColumnVector& kernely() const { return p_kernely; }
const NEWMAT::ColumnVector& kernelz() const { return p_kernelz; }
};
......@@ -132,8 +130,8 @@ namespace MISCMATHS {
}
void setkernel(const ColumnVector& kx, const ColumnVector& ky,
const ColumnVector& kz, int wx, int wy, int wz)
void setkernel(const NEWMAT::ColumnVector& kx, const NEWMAT::ColumnVector& ky,
const NEWMAT::ColumnVector& kz, int wx, int wy, int wz)
{
// see if already in list:
storedkernel = new kernelstorage(kx,ky,kz,wx,wy,wz);
......@@ -158,21 +156,21 @@ namespace MISCMATHS {
//////// Support functions /////////
float kernelval(float x, int w, const ColumnVector& kernel);
float kernelval(float x, int w, const NEWMAT::ColumnVector& kernel);
float sincfn(float x);
float hanning(float x, int w);
float blackman(float x, int w);
float rectangular(float x, int w);
ColumnVector sinckernel1D(const string& sincwindowtype, int w, int n);
kernel sinckernel(const string& sincwindowtype, int w, int nstore);
kernel sinckernel(const string& sincwindowtype,
NEWMAT::ColumnVector sinckernel1D(const std::string& sincwindowtype, int w, int n);
kernel sinckernel(const std::string& sincwindowtype, int w, int nstore);
kernel sinckernel(const std::string& sincwindowtype,
int wx, int wy, int wz, int nstore);
float extrapolate_1d(const ColumnVector& data, const int index);
float interpolate_1d(const ColumnVector& data, const float index);
float kernelinterpolation_1d(const ColumnVector& data, float index, const ColumnVector& userkernel, int width);
float kernelinterpolation_1d(const ColumnVector& data, float index);
float kernelinterpolation_1d(RowVector data, float index);
float hermiteinterpolation_1d(const ColumnVector& data, int p1, int p4, float t);
float extrapolate_1d(const NEWMAT::ColumnVector& data, const int index);
float interpolate_1d(const NEWMAT::ColumnVector& data, const float index);
float kernelinterpolation_1d(const NEWMAT::ColumnVector& data, float index, const NEWMAT::ColumnVector& userkernel, int width);
float kernelinterpolation_1d(const NEWMAT::ColumnVector& data, float index);
float kernelinterpolation_1d(NEWMAT::RowVector data, float index);
float hermiteinterpolation_1d(const NEWMAT::ColumnVector& data, int p1, int p4, float t);
}
#endif
......@@ -20,12 +20,6 @@
#include "miscmaths.h"
#define WANT_STREAM
#define WANT_MATH
using namespace MISCMATHS;
using namespace NEWMAT;
using namespace std;
///////////////////////////////////////////////////////
//fminsearch.m
......@@ -35,7 +29,7 @@ namespace MISCMATHS {
class pair_comparer
{
public:
bool operator()(const pair<float,ColumnVector>& p1,const pair<float,ColumnVector>& p2) const
bool operator()(const pair<float,NEWMAT::ColumnVector>& p1,const pair<float,NEWMAT::ColumnVector>& p2) const
{
return p1.first < p2.first;
}
......@@ -44,35 +38,35 @@ public:
class EvalFunction;
class gEvalFunction;
float diff1(const ColumnVector& x, const EvalFunction& func, int i,float h,int errorord=4);// finite diff derivative
float diff1(const NEWMAT::ColumnVector& x, const EvalFunction& func, int i,float h,int errorord=4);// finite diff derivative
float diff2(const ColumnVector& x, const EvalFunction& func, int i,float h,int errorord=4);// finite diff 2nd derivative
float diff2(const NEWMAT::ColumnVector& x, const EvalFunction& func, int i,float h,int errorord=4);// finite diff 2nd derivative
float diff2(const ColumnVector& x, const EvalFunction& func, int i,int j,float h,int errorord=4);// finite diff cross derivative
float diff2(const NEWMAT::ColumnVector& x, const EvalFunction& func, int i,int j,float h,int errorord=4);// finite diff cross derivative
ReturnMatrix gradient(const ColumnVector& x, const EvalFunction& func,float h,int errorord=4);// finite diff derivative vector
NEWMAT::ReturnMatrix gradient(const NEWMAT::ColumnVector& x, const EvalFunction& func,float h,int errorord=4);// finite diff derivative vector
ReturnMatrix hessian(const ColumnVector& x, const EvalFunction& func,float h,int errorord=4);// finite diff hessian
NEWMAT::ReturnMatrix hessian(const NEWMAT::ColumnVector& x, const EvalFunction& func,float h,int errorord=4);// finite diff hessian
void minsearch(ColumnVector& x, const EvalFunction& func, ColumnVector& paramstovary);
void minsearch(NEWMAT::ColumnVector& x, const EvalFunction& func, NEWMAT::ColumnVector& paramstovary);
void scg(ColumnVector& x, const gEvalFunction& func, ColumnVector& paramstovary, float tol = 0.0000001, float eps=1e-16, int niters=500);
void scg(NEWMAT::ColumnVector& x, const gEvalFunction& func, NEWMAT::ColumnVector& paramstovary, float tol = 0.0000001, float eps=1e-16, int niters=500);
class EvalFunction
{//Function where gradient is not analytic (or you are too lazy to work it out) (required for fminsearch)
public:
EvalFunction(){}
virtual float evaluate(const ColumnVector& x) const = 0; //evaluate the function
virtual float evaluate(const NEWMAT::ColumnVector& x) const = 0; //evaluate the function
virtual ~EvalFunction(){};
virtual void minimize(ColumnVector& x)
virtual void minimize(NEWMAT::ColumnVector& x)
{
ColumnVector paramstovary(x.Nrows());
NEWMAT::ColumnVector paramstovary(x.Nrows());
paramstovary = 1;
minsearch(x,*this,paramstovary);
}
virtual void minimize(ColumnVector& x, ColumnVector& paramstovary)
virtual void minimize(NEWMAT::ColumnVector& x, NEWMAT::ColumnVector& paramstovary)
{
minsearch(x,*this,paramstovary);
}
......@@ -88,17 +82,17 @@ public:
gEvalFunction() : EvalFunction(){}
// evaluate is inherited from EvalFunction
virtual ReturnMatrix g_evaluate(const ColumnVector& x) const = 0; //evaluate the gradient
virtual NEWMAT::ReturnMatrix g_evaluate(const NEWMAT::ColumnVector& x) const = 0; //evaluate the gradient
virtual ~gEvalFunction(){};
virtual void minimize(ColumnVector& x)
virtual void minimize(NEWMAT::ColumnVector& x)
{
ColumnVector paramstovary(x.Nrows());
NEWMAT::ColumnVector paramstovary(x.Nrows());
paramstovary = 1;
scg(x,*this,paramstovary);
}
virtual void minimize(ColumnVector& x, ColumnVector& paramstovary)
virtual void minimize(NEWMAT::ColumnVector& x, NEWMAT::ColumnVector& paramstovary)
{
scg(x,*this,paramstovary);
}
......
This diff is collapsed.
......@@ -16,48 +16,46 @@
#include "cprob/libprob.h"
#include "stdlib.h"
using namespace NEWMAT;
namespace MISCMATHS {
// ReturnMatrix betarnd(const int dim1, const int dim2,
// const float a, const float b);
ReturnMatrix betapdf(const RowVector& vals,
NEWMAT::ReturnMatrix betapdf(const NEWMAT::RowVector& vals,
const float a, const float b);
ReturnMatrix unifrnd(const int dim1 = 1, const int dim2 = -1,
NEWMAT::ReturnMatrix unifrnd(const int dim1 = 1, const int dim2 = -1,
const float start = 0, const float end = 1);
ReturnMatrix normrnd(const int dim1 = 1, const int dim2 = -1,
NEWMAT::ReturnMatrix normrnd(const int dim1 = 1, const int dim2 = -1,
const float mu = 0, const float sigma = 1);
// returns nsamps*nparams matrix:
ReturnMatrix mvnrnd(const RowVector& mu, const SymmetricMatrix& covar, int nsamp = 1);
NEWMAT::ReturnMatrix mvnrnd(const NEWMAT::RowVector& mu, const NEWMAT::SymmetricMatrix& covar, int nsamp = 1);
float mvnpdf(const RowVector& vals, const RowVector& mu, const SymmetricMatrix& covar);
float mvnpdf(const NEWMAT::RowVector& vals, const NEWMAT::RowVector& mu, const NEWMAT::SymmetricMatrix& covar);
float bvnpdf(const RowVector& vals, const RowVector& mu, const SymmetricMatrix& covar);
float bvnpdf(const NEWMAT::RowVector& vals, const NEWMAT::RowVector& mu, const NEWMAT::SymmetricMatrix& covar);
float normpdf(const float val, const float mu = 0, const float var = 1);
float lognormpdf(const float val, const float mu = 0, const float var = 1);
ReturnMatrix normpdf(const RowVector& vals, const float mu = 0, const float var = 1);
NEWMAT::ReturnMatrix normpdf(const NEWMAT::RowVector& vals, const float mu = 0, const float var = 1);
ReturnMatrix normpdf(const RowVector& vals, const RowVector& mus,
const RowVector& vars);
NEWMAT::ReturnMatrix normpdf(const NEWMAT::RowVector& vals, const NEWMAT::RowVector& mus,
const NEWMAT::RowVector& vars);
ReturnMatrix normcdf(const RowVector& vals, const float mu = 0, const float var = 1);
NEWMAT::ReturnMatrix normcdf(const NEWMAT::RowVector& vals, const float mu = 0, const float var = 1);
ReturnMatrix gammapdf(const RowVector& vals, const float mu = 0, const float var = 1);
NEWMAT::ReturnMatrix gammapdf(const NEWMAT::RowVector& vals, const float mu = 0, const float var = 1);
ReturnMatrix gammacdf(const RowVector& vals, const float mu = 0, const float var = 1);
NEWMAT::ReturnMatrix gammacdf(const NEWMAT::RowVector& vals, const float mu = 0, const float var = 1);
// ReturnMatrix gammarnd(const int dim1, const int dim2,
// NEWMAT::ReturnMatrix gammarnd(const int dim1, const int dim2,
// const float a, const float b);
// returns n! * n matrix of all possible permutations
ReturnMatrix perms(const int n);
NEWMAT::ReturnMatrix perms(const int n);
class Mvnormrandm
......@@ -65,42 +63,42 @@ namespace MISCMATHS {
public:
Mvnormrandm(){}
Mvnormrandm(const RowVector& pmu, const SymmetricMatrix& pcovar) :
Mvnormrandm(const NEWMAT::RowVector& pmu, const NEWMAT::SymmetricMatrix& pcovar) :
mu(pmu),
covar(pcovar)
{
Matrix eig_vec;
DiagonalMatrix eig_val;
NEWMAT::Matrix eig_vec;
NEWMAT::DiagonalMatrix eig_val;
EigenValues(covar,eig_val,eig_vec);
covarw = sqrt(eig_val)*eig_vec.t();
}
ReturnMatrix next(int nsamp = 1) const
NEWMAT::ReturnMatrix next(int nsamp = 1) const
{
Matrix ret = ones(nsamp, 1)*mu + normrnd(nsamp,mu.Ncols())*covarw;
NEWMAT::Matrix ret = ones(nsamp, 1)*mu + normrnd(nsamp,mu.Ncols())*covarw;
ret.Release();
return ret;
}
ReturnMatrix next(const RowVector& pmu, int nsamp = 1)
NEWMAT::ReturnMatrix next(const NEWMAT::RowVector& pmu, int nsamp = 1)
{
mu=pmu;
Matrix ret = ones(nsamp, 1)*mu + normrnd(nsamp,mu.Ncols())*covarw;
NEWMAT::Matrix ret = ones(nsamp, 1)*mu + normrnd(nsamp,mu.Ncols())*covarw;
ret.Release();
return ret;
}
void setcovar(const SymmetricMatrix& pcovar)
void setcovar(const NEWMAT::SymmetricMatrix& pcovar)
{
covar=pcovar;
mu.ReSize(covar.Nrows());
mu=0;
Matrix eig_vec;
DiagonalMatrix eig_val;
NEWMAT::Matrix eig_vec;
NEWMAT::DiagonalMatrix eig_val;
EigenValues(covar,eig_val,eig_vec);
covarw = sqrt(eig_val)*eig_vec.t();
......@@ -108,10 +106,10 @@ namespace MISCMATHS {
private:
RowVector mu;
SymmetricMatrix covar;
NEWMAT::RowVector mu;
NEWMAT::SymmetricMatrix covar;
Matrix covarw;
NEWMAT::Matrix covarw;
};
}
......
......@@ -16,19 +16,17 @@
#include "armawrap/newmatap.h"
#include "string"
using namespace NEWMAT;
namespace MISCMATHS {
float optimise1d(ColumnVector &pt, const ColumnVector dir,
const ColumnVector tol, int &iterations_done,
float (*func)(const ColumnVector &), int max_iter,
float optimise1d(NEWMAT::ColumnVector &pt, const NEWMAT::ColumnVector dir,
const NEWMAT::ColumnVector tol, int &iterations_done,
float (*func)(const NEWMAT::ColumnVector &), int max_iter,
float &init_value, float boundguess);
float optimise(ColumnVector &pt, int numopt, const ColumnVector &tol,
float (*func)(const ColumnVector &), int &iterations_done,
int max_iter, const ColumnVector& boundguess,
float optimise(NEWMAT::ColumnVector &pt, int numopt, const NEWMAT::ColumnVector &tol,
float (*func)(const NEWMAT::ColumnVector &), int &iterations_done,
int max_iter, const NEWMAT::ColumnVector& boundguess,
const std::string type="brent");
}
......
......@@ -17,8 +17,6 @@
#include "armawrap/newmatap.h"
#include "armawrap/newmatio.h"
using namespace NEWMAT;
namespace MISCMATHS {
class Derivative
......@@ -29,20 +27,20 @@ public:
// x is time point to evaluate at
// y is state variables
// paramvalues are "constants" in the diff eqn
virtual const ColumnVector& evaluate(float x,const ColumnVector& y,const ColumnVector& paramvalues) const = 0;
virtual const NEWMAT::ColumnVector& evaluate(float x,const NEWMAT::ColumnVector& y,const NEWMAT::ColumnVector& paramvalues) const = 0;
virtual ~Derivative(){};
protected:
int ny;
mutable ColumnVector dy;
mutable NEWMAT::ColumnVector dy;
};
void rk(ColumnVector& ret, const ColumnVector& y, const ColumnVector& dy, float x, float h, const Derivative& deriv,const ColumnVector& paramvalues);
void rk(NEWMAT::ColumnVector& ret, const NEWMAT::ColumnVector& y, const NEWMAT::ColumnVector& dy, float x, float h, const Derivative& deriv,const NEWMAT::ColumnVector& paramvalues);
void rkqc(ColumnVector& y, float& x, float& hnext, ColumnVector& dy, float htry, float eps, const Derivative& deriv,const ColumnVector& paramvalues);
void rkqc(NEWMAT::ColumnVector& y, float& x, float& hnext, NEWMAT::ColumnVector& dy, float htry, float eps, const Derivative& deriv,const NEWMAT::ColumnVector& paramvalues);
void runge_kutta(Matrix& yp, ColumnVector& xp, ColumnVector& hp, const ColumnVector& ystart, float x1, float x2, float eps, float hmin, const Derivative& deriv,const ColumnVector& paramvalues);
void runge_kutta(NEWMAT::Matrix& yp, NEWMAT::ColumnVector& xp, NEWMAT::ColumnVector& hp, const NEWMAT::ColumnVector& ystart, float x1, float x2, float eps, float hmin, const Derivative& deriv,const NEWMAT::ColumnVector& paramvalues);
}
......
......@@ -16,16 +16,13 @@
#include "armawrap/newmat.h"
#include "armawrap/newmatio.h"
using namespace NEWMAT;
using namespace std;
namespace MISCMATHS {
class SparseMatrix
{
public:
typedef map<int,double> Row;
typedef std::map<int,double> Row;
SparseMatrix() : nrows(0), ncols(0) {}
......@@ -45,12 +42,12 @@ namespace MISCMATHS {
return *this;
}
SparseMatrix(const Matrix& pmatin)
SparseMatrix(const NEWMAT::Matrix& pmatin)
{
operator=(pmatin);
}
const SparseMatrix& operator=(const Matrix& pmatin);
const SparseMatrix& operator=(const NEWMAT::Matrix& pmatin);
// void ReSize(int pnrows, int pncols)
void ReSize(int pnrows, int pncols);
......@@ -62,16 +59,16 @@ namespace MISCMATHS {
void transpose(SparseMatrix& ret);
ReturnMatrix RowAsColumn(int r) const;
NEWMAT::ReturnMatrix RowAsColumn(int r) const;
int maxnonzerosinrow() const;
void permute(const ColumnVector& p, SparseMatrix& pA);
void permute(const NEWMAT::ColumnVector& p, SparseMatrix& pA);
const double operator()(int x, int y) const
{
double ret = 0.0;
map<int,double>::const_iterator it=data[x-1].find(y-1);
std::map<int,double>::const_iterator it=data[x-1].find(y-1);
if(it != data[x-1].end())
ret = (*it).second;
......@@ -111,7 +108,7 @@ namespace MISCMATHS {
const Row& row(int r) const { return data[r-1]; }
ReturnMatrix AsMatrix() const;
NEWMAT::ReturnMatrix AsMatrix() const;
int Nrows() const { return nrows; }
int Ncols() const { return ncols; }
......@@ -128,20 +125,20 @@ namespace MISCMATHS {
int nrows;
int ncols;
vector<map<int,double> > data;
std::vector<map<int,double> > data;
};
void multiply(const SparseMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret);
void multiply(const DiagonalMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret);
void multiply(const NEWMAT::DiagonalMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret);
void multiply(const SparseMatrix& lm, const ColumnVector& rm, ColumnVector& ret);
void multiply(const SparseMatrix& lm, const NEWMAT::ColumnVector& rm, NEWMAT::ColumnVector& ret);
void multiply(const SparseMatrix& lm, const SparseMatrix::Row& rm, ColumnVector& ret);
void multiply(const SparseMatrix& lm, const SparseMatrix::Row& rm, NEWMAT::ColumnVector& ret);
void add(const SparseMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret);
void colvectosparserow(const ColumnVector& col, SparseMatrix::Row& row);
void colvectosparserow(const NEWMAT::ColumnVector& col, SparseMatrix::Row& row);
void vertconcat(const SparseMatrix& A, const SparseMatrix& B, SparseMatrix& ret);
......
......@@ -18,26 +18,24 @@
#include "sparse_matrix.h"
#include "armawrap/newmat.h"
using namespace NEWMAT;
namespace MISCMATHS {
float quadratic(const ColumnVector& m, const SparseMatrix& C);
float quadratic(const NEWMAT::ColumnVector& m, const SparseMatrix& C);
void speye(int n, SparseMatrix& ret);
void chol(const SparseMatrix& A, SparseMatrix& U, SparseMatrix& L);
void inv(const SparseMatrix& U, const SparseMatrix& L, SparseMatrix& ret);
void solvefortracex(const SparseMatrix& U, const SparseMatrix& L, const SparseMatrix& b1, const SparseMatrix& b2, float& tr1, float& tr2);
void solveforx(const SparseMatrix& U, const SparseMatrix& L, const ColumnVector& b, ColumnVector& x);
void solveforx(const SparseMatrix& A, const ColumnVector& b, ColumnVector& x, float tol = 0.001, int kmax = 500);
void solveforx(const SparseMatrix& A, const ColumnVector& b, SparseMatrix& x);
void solveforx(const SparseMatrix& U, const SparseMatrix& L, const NEWMAT::ColumnVector& b, NEWMAT::ColumnVector& x);
void solveforx(const SparseMatrix& A, const NEWMAT::ColumnVector& b, NEWMAT::ColumnVector& x, float tol = 0.001, int kmax = 500);
void solveforx(const SparseMatrix& A, const NEWMAT::ColumnVector& b, SparseMatrix& x);
void solveforx(const SparseMatrix& A, const SparseMatrix& b, SparseMatrix& x);
float solvefortracex(const SparseMatrix& A, const SparseMatrix& b, SparseMatrix& x, int nsamps = 50, float tol = 0.001);
void solve(const SparseMatrix& A, const Matrix& b, SparseMatrix& x);
void solve(const SparseMatrix& A, const NEWMAT::Matrix& b, SparseMatrix& x);
void addto(SparseMatrix& A, const SparseMatrix& B, float S);
void symmetric_addto(SparseMatrix& A, const SparseMatrix& B, float S);
void addto(const SparseMatrix::Row& A, const SparseMatrix::Row& B, float S);
void addto(SparseMatrix& A, const Matrix& B);
void cov(const ColumnVector& A, SparseMatrix& ret);
void addto(SparseMatrix& A, const NEWMAT::Matrix& B);
void cov(const NEWMAT::ColumnVector& A, SparseMatrix& ret);
}
#endif
......@@ -15,8 +15,6 @@
#include "armawrap/newmatio.h"
#include "base2z.h"
using namespace NEWMAT;
namespace MISCMATHS {
class T2z : public Base2z
......@@ -28,9 +26,9 @@ namespace MISCMATHS {
float convert(float t, int dof,double *newp=NULL);
float converttologp(float t, int dof);
static void ComputePs(const ColumnVector& p_vars, const ColumnVector& p_cbs, int p_dof, ColumnVector& p_ps);
static void ComputeZStats(const ColumnVector& p_vars, const ColumnVector& p_cbs, int p_dof, ColumnVector& p_zs);
static void ComputeZStats(const ColumnVector& p_vars, const ColumnVector& p_cbs, const ColumnVector& p_dof, ColumnVector& p_zs);
static void ComputePs(const NEWMAT::ColumnVector& p_vars, const NEWMAT::ColumnVector& p_cbs, int p_dof, NEWMAT::ColumnVector& p_ps);
static void ComputeZStats(const NEWMAT::ColumnVector& p_vars, const NEWMAT::ColumnVector& p_cbs, int p_dof, NEWMAT::ColumnVector& p_zs);
static void ComputeZStats(const NEWMAT::ColumnVector& p_vars, const NEWMAT::ColumnVector& p_cbs, const NEWMAT::ColumnVector& p_dof, NEWMAT::ColumnVector& p_zs);
private:
T2z() : Base2z()
......
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