#include "haarOct.h" // convert an octave double array to a C array void ado2c(const Matrix & M, double * X) { int n = M.rows(); int m = M.cols(); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { X[i*m+j] = M(i,j); } } } // convert a C array to octave double array Matrix adc2o(const double * X, int n, int m) { Matrix M(dim_vector(n,m)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { M(i,j) = X[i*m+j]; } } return M; } int is_positive_integer(double x) { return (floor(x) == x && x >= 0); } int CheckArgs(const octave_value_list & args) { int ret = 0; if(args.length() < 2) { ret = -1; error("Not enough arguments."); } else if(!args(0).is_real_matrix()) { ret = -1; error("First argument is not a real matrix."); } else if(!args(1).is_real_scalar() || !is_positive_integer(args(1).scalar_value())) { ret = -1; error("Second argument is not a positive integer"); } return ret; }