-
Notifications
You must be signed in to change notification settings - Fork 14
/
dpotrs.cpp
67 lines (43 loc) · 1.08 KB
/
dpotrs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <math.h>
#include <algorithm>
#include "dpotrs.h"
void dpotrs(double **A, double *B, int msize)
{
int info;
double *a;
char UPLO='L';
int NRHS=1;
a = dpotrs_ctof(A, msize, msize);
dpotrs_(&UPLO, &msize, &NRHS, a, &msize, B, &msize, &info);
dpotrs_ftoc(a, A, msize, msize);
delete a;
}
void vector_dpotrsInfo(double *A, double *B, int msize, int &info)
{
char UPLO='L';
int NRHS=1;
dpotrs_(&UPLO, &msize, &NRHS, A, &msize, B, &msize, &info);
}
void dpotrsInfo(double **A, double *B, int msize, int &info)
{
double *a;
char UPLO='L';
int NRHS=1;
a = dpotrs_ctof(A, msize, msize);
dpotrs_(&UPLO, &msize, &NRHS, a, &msize, B, &msize, &info);
dpotrs_ftoc(a, A, msize, msize);
delete a;
}
double* dpotrs_ctof(double **in, int rows, int cols)
{
double *out;
int i, j;
out = new double[rows*cols];
for (i=0; i<rows; i++) for (j=0; j<cols; j++) out[i+j*rows] = in[i][j];
return(out);
}
void dpotrs_ftoc(double *in, double **out, int rows, int cols)
{
int i, j;
for (i=0; i<rows; i++) for (j=0; j<cols; j++) out[i][j] = in[i+j*rows];
}