2
0
Fork 0
CVE/CVE_C/src/cve.h

99 lines
3.1 KiB
C

/* Include Guard */
#ifndef CVE_INCLUDE_GUARD_H_
#define CVE_INCLUDE_GUARD_H_
#include <string.h> // `mem*` functions.
#include <math.h> // sqrt, exp, ...
#include <R.h>
#include <Rinternals.h>
#include <R_ext/BLAS.h>
#include <R_ext/Lapack.h>
#define CVE_MEM_CHUNK_SIZE 2032
#define CVE_MEM_CHUNK_SMALL 1016
void cve_simple_sub(const int n, const int p, const int q,
const double *X, const double *Y, const double h,
const double tau_init, const double tol_init,
const int epochs, const 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 int n,
const double *Y,
const double *vecK,
const double *colSums,
double *y1, double *L);
void scaling(const int n,
const double *Y, const double *y1, const double *L,
const double *vecD, const double *vecK,
const double *colSums,
double *vecS);
/* rStiefl */
void rStiefl(const int p, const int q, double *V,
double *workMem, int workLen);
/* MATRIX */
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_ */