50 lines
1.8 KiB
C
50 lines
1.8 KiB
C
#ifndef LINALG_H
|
|
#define LINALG_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <gsl/gsl_math.h>
|
|
#include <gsl/gsl_eigen.h>
|
|
#include <gsl/gsl_blas.h>
|
|
#include <gsl/gsl_linalg.h>
|
|
#include <memory.h>
|
|
|
|
#define ERROR(condition, msg, ...) if(condition){fprintf(stderr, msg, ##__VA_ARGS__); exit(1);}
|
|
#define FCMP(x, y) gsl_fcmp(x, y, 1e-10)
|
|
|
|
typedef struct _workspace {
|
|
int n;
|
|
gsl_eigen_nonsymmv_workspace *work_nonsymmv;
|
|
gsl_eigen_symmv_workspace *work_symmv;
|
|
gsl_vector *work_sv;
|
|
gsl_vector_complex *eval_complex;
|
|
gsl_matrix_complex *evec_complex;
|
|
gsl_vector *eval_real;
|
|
gsl_matrix *evec_real;
|
|
gsl_matrix *tmp;
|
|
gsl_permutation *permutation;
|
|
gsl_matrix *stack[20];
|
|
} workspace_t;
|
|
|
|
workspace_t *workspace_alloc(int n);
|
|
void workspace_free(workspace_t *workspace);
|
|
void invert(gsl_matrix *in, gsl_matrix *out, workspace_t *ws);
|
|
void conjugate(gsl_matrix *in, gsl_matrix *conjugator, gsl_matrix *out, workspace_t *ws);
|
|
void multiply(gsl_matrix *a, gsl_matrix *b, gsl_matrix *out);
|
|
void multiply_right(gsl_matrix *a, gsl_matrix *b, workspace_t *ws);
|
|
void multiply_left(gsl_matrix *a, gsl_matrix *b, workspace_t *ws);
|
|
void multiply_many(workspace_t *ws, gsl_matrix *out, int n, ...);
|
|
void cartan_calc(gsl_matrix *g, double *mu, workspace_t *ws);
|
|
void initialize(gsl_matrix *g, double *data, int x, int y);
|
|
void rotation_matrix(gsl_matrix *g, double *vector);
|
|
int jordan_calc(gsl_matrix *g, double *mu, workspace_t *ws);
|
|
double trace(gsl_matrix *g);
|
|
double determinant(gsl_matrix *g, workspace_t *ws);
|
|
int eigenvectors(gsl_matrix *g, gsl_matrix *evec, workspace_t *ws);
|
|
int real_eigenvectors(gsl_matrix *g, gsl_matrix *evec, workspace_t *ws);
|
|
void eigenvectors_symm(gsl_matrix *g, gsl_vector *eval, gsl_matrix *evec, workspace_t *ws);
|
|
int diagonalize_symmetric_form(gsl_matrix *A, gsl_matrix *cob, workspace_t *ws);
|
|
|
|
#endif
|