55 double *eigv =
gv_calloc(n,
sizeof(
double));
60 srand((
unsigned)random_seed);
63 for (i = 0; i < n; i++) u[i] =
drand();
65 if (res > 0) res = 1/res;
66 for (i = 0; i < n; i++) {
80 for (i = 0; i < n; i++) vv[i] = u[i];
82 if (unorm > 0) unorm = 1/unorm;
86 for (i = 0; i < n; i++) {
88 res = res + u[i]*v[i];
void SparseMatrix_multiply_vector(SparseMatrix A, double *v, double **res)
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
double vector_product(int n, double *x, double *y)
static const double tolerance
double * power_method(void *A, int n, int random_seed)