/* Include Guard */ #ifndef CVE_INCLUDE_GUARD_H_ #define CVE_INCLUDE_GUARD_H_ #include // `mem*` functions. #include // sqrt, exp, ... #include #include #include #include #define CVE_MEM_CHUNK_SIZE 2032 #define CVE_MEM_CHUNK_SMALL 1016 /* Bis masks for method types */ #define CVE_METHOD_WEIGHTED 1 // typedef struct { // unsigned int nrow; // unsigned int ncol; // unsigned int memsize; // double *data; // } mat; // mat* Matrix(const unsigned int nrow, const unsigned int ncol); void cve_sub(const int n, const int p, const int q, const double *X, const double *Y, const double h, const unsigned int method, const double momentum, const double tau_init, const double tol_init, const double slack, const double gamma, const int maxIter, int attempts, double *V, double *L, SEXP logger, SEXP loggerEnv); void callLogger(SEXP logger, SEXP env, const int attempt, const int epoch, const double* L, const int lenL, const double* V, const int nrowV, const int ncolV, const double tau); /* CVE sub-routines */ int getWorkLen(const int n, const int p, const int q); double cost(const unsigned int method, const int n, const double *Y, const double *vecK, const double *colSums, double *y1, double *L); void scaling(const unsigned int method, const int n, const double *Y, const double *y1, const double *L, const double *vecD, const double *vecK, const double *colSums, double *vecS); /* rStiefel */ void rStiefel(const int p, const int q, double *V, double *workMem, int workLen); /* MATRIX */ double sum(const double *A, const int nelem); double norm(const double *A, const int nrow, const int ncol, const char *type); void matrixprod(const double *A, const int nrowA, const int ncolA, const double *B, const int nrowB, const int ncolB, double *C); void crossprod(const double *A, const int nrowA, const int ncolA, const double *B, const int nrowB, const int ncolB, double *C); void skew(const int nrow, const int ncol, double alpha, const double *A, const double *B, double beta, double *C); void nullProj(const double *B, const int nrowB, const int ncolB, double *Q); void scale(const double s, double *A, const int nelem); void cayleyTransform(const int p, const int q, const double *A, const double *B, double *X, double *workMem); /* Row and column opperations. */ void rowSums(const double *A, const int nrow, const int ncol, double *sum); void colSums(const double *A, const int nrow, const int ncol, double *sum); void rowSquareSums(const double *A, const int nrow, const int ncol, double *sum); void rowSumsSymVec(const double *Avec, const int nrow, const double diag, double *sum); void rowDiffs(const double* X, const int nrow, const int ncol, double *diffs); void rowDiffSquareSums(const double* X, const int nrow, const int ncol, double *sum); /* SWEEP */ void rowSweep(const double *A, const int nrow, const int ncol, const char* op, const double *v, // vector of length nrow double *C); #endif /* CVE_INCLUDE_GUARD_H_ */