26 (
vtx_data * A,
double *x,
double *b,
int n,
double tol,
33 double alpha, beta, r_r, r_r_new, p_Ap;
34 double *r =
N_GNEW(n,
double);
35 double *p =
N_GNEW(n,
double);
36 double *Ap =
N_GNEW(n,
double);
37 double *Ax =
N_GNEW(n,
double);
38 double *alphap =
N_GNEW(n,
double);
40 double *orth_b =
N_GNEW(n,
double);
49 for (i = 0; i < max_iterations && max_abs(n, r) > tol; i++) {
61 if (i < max_iterations - 1) {
71 agerr (
AGERR,
"conjugate_gradient: unexpected length 0 vector\n");
99 (
float **A,
double *x,
double *b,
int n,
double tol,
100 int max_iterations,
boolean ortho1) {
106 double alpha, beta, r_r, r_r_new, p_Ap;
107 double *r =
N_GNEW(n,
double);
108 double *p =
N_GNEW(n,
double);
109 double *Ap =
N_GNEW(n,
double);
110 double *Ax =
N_GNEW(n,
double);
111 double *alphap =
N_GNEW(n,
double);
113 double *orth_b =
N_GNEW(n,
double);
124 for (i = 0; i < max_iterations && max_abs(n, r) > tol; i++) {
136 if (i < max_iterations - 1) {
147 agerr (
AGERR,
"conjugate_gradient: unexpected length 0 vector\n");
150 beta = r_r_new / r_r;
169 double tol,
int max_iterations)
177 double alpha, beta, r_r, r_r_new, p_Ap;
178 float *r =
N_NEW(n,
float);
179 float *p =
N_NEW(n,
float);
180 float *Ap =
N_NEW(n,
float);
181 float *Ax =
N_NEW(n,
float);
197 for (i = 0; i < max_iterations && max_absf(n, r) > tol; i++) {
215 if (i < max_iterations - 1) {
223 agerr (
AGERR,
"conjugate_gradient: unexpected length 0 vector\n");
226 beta = r_r_new / r_r;
void vectors_additionf(int n, float *vector1, float *vector2, float *result)
void orthog1(int n, double *vec)
void copy_vectorf(int n, float *source, float *dest)
void vectors_addition(int n, double *vector1, double *vector2, double *result)
void copy_vector(int n, double *source, double *dest)
int agerr(agerrlevel_t level, const char *fmt,...)
void vectors_mult_additionf(int n, float *vector1, float alpha, float *vector2)
void right_mult_with_vector_f(float **matrix, int n, double *vector, double *result)
int conjugate_gradient(vtx_data *A, double *x, double *b, int n, double tol, int max_iterations)
void vectors_scalar_multf(int n, float *vector, float alpha, float *result)
double vectors_inner_productf(int n, float *vector1, float *vector2)
double vectors_inner_product(int n, double *vector1, double *vector2)
void orthog1f(int n, float *vec)
void vectors_substractionf(int n, float *vector1, float *vector2, float *result)
int conjugate_gradient_f(float **A, double *x, double *b, int n, double tol, int max_iterations, boolean ortho1)
void vectors_subtraction(int n, double *vector1, double *vector2, double *result)
void right_mult_with_vector_ff(float *packed_matrix, int n, float *vector, float *result)
void vectors_scalar_mult(int n, double *vector, double alpha, double *result)
int conjugate_gradient_mkernel(float *A, float *x, float *b, int n, double tol, int max_iterations)
void right_mult_with_vector(vtx_data *matrix, int n, double *vector, double *result)