00001 #ifndef __NUMERICAL_TOOLS_
00002 #define __NUMERICAL_TOOLS_
00003
00004 #include "StreamOutput.h"
00005 #include "Framework.h"
00006
00007 #include <math.h>
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010
00011 #include <malloc.h>
00012 #include <mkl.h>
00013 #include <assert.h>
00014 #include <cstring>
00015
00016
00017 #define ALLOC_MEM 1
00018 #define FREE_MEM 2
00019
00020 using namespace std;
00021
00030 class NumericalTools : public Framework
00031 {
00032 public:
00033 NumericalTools();
00034 ~NumericalTools();
00035
00036 static void RidgeRegressionMultisolutionSinglecallGELSS ( REAL *A, REAL *b, REAL *x, int n, int m, int k, REAL lambda, bool isRowMajor=false );
00037 static void RidgeRegressionMultisolutionSinglecall ( REAL *A, REAL *b, REAL *x, int n, int m, int k, REAL lambda, bool isRowMajor, double* rideModifier=0 );
00038 int RidgeRegressionNonNegSinglecall ( REAL *A, REAL *b, REAL *x, int n, int m, REAL lamda, REAL eps, int maxIter, bool isRowMajor=true, int debug=0 );
00039
00040 static void RidgeRegressionMultisolutionMulticall ( REAL *A, REAL *b, REAL *x, int n, int m, int k, REAL lambda, int alloc=0, bool isRowMajor=false );
00041 static int RidgeRegressionNonNegmulticall ( REAL *A, REAL *b, REAL *x, int n, int m, REAL lamda, REAL eps, int maxIter, int alloc=0, bool isRowMajor=true, int debug=0 );
00042
00043 static void LogisticRegressionMultisolutionSinglecall ( REAL *A, REAL *b, REAL *x, int n, int m, int k, REAL lambda, REAL offset = 0.0, REAL scale = 1.0, bool isRowMajor=true );
00044
00045 static REAL getNormRandomNumber ( REAL mean, REAL std );
00046 static REAL getUniformRandomNumber ( REAL min, REAL max );
00047 static REAL clipValue ( REAL value, REAL min, REAL max );
00048
00049 private:
00050
00051 };
00052
00053 #endif