Canoe
Comprehensive Atmosphere N' Ocean Engine
band_multiply.c
Go to the documentation of this file.
1
#undef IMIN
2
#define IMIN(i, j) \
3
({ \
4
const int _i = (int)(i); \
5
const int _j = (int)(j); \
6
_i < _j ? _i : _j; \
7
})
8
9
#undef IMAX
10
#define IMAX(i, j) \
11
({ \
12
const int _i = (int)(i); \
13
const int _j = (int)(j); \
14
_i > _j ? _i : _j; \
15
})
16
17
/*======================= band_multiply() ====================================*/
18
/*
19
* Compute matrix muliplication b = A.x, where A is in the compact-storage
20
* form of a band-diagonal matrix.
21
* Based on Numerical Recipes in C, banmul(), p. 52.
22
* Assumes zero-based indexing.
23
*/
24
25
#undef A
26
#define A(i, j) a[(m1 + m2 + 1) * (i) + (j)]
27
28
void
band_multiply
(
int
n,
int
m1,
int
m2,
double
*
a
,
double
*x,
double
*
b
) {
29
int
i,
j
, k, tmploop;
30
31
for
(i = 0; i < n; i++) {
32
k = i - m1;
33
tmploop =
IMIN
(m1 + m2 + 1, n - k);
34
b
[i] = 0.;
35
for
(
j
=
IMAX
(0, -k);
j
< tmploop;
j
++) {
36
b
[i] +=
A
(i,
j
) * x[
j
+ k];
37
}
38
}
39
40
return
;
41
}
42
43
/*======================= end of band_multiply() =============================*/
IMIN
#define IMIN(i, j)
Definition:
band_multiply.c:2
band_multiply
void band_multiply(int n, int m1, int m2, double *a, double *x, double *b)
Definition:
band_multiply.c:28
IMAX
#define IMAX(i, j)
Definition:
band_multiply.c:10
A
#define A(i, j)
Definition:
band_multiply.c:26
fit_ammonia.b
b
Definition:
fit_ammonia.py:8
fit_ammonia.a
a
Definition:
fit_ammonia.py:8
make_plots.j
j
Definition:
make_plots.py:26
src
climath
band_multiply.c
Generated by
1.9.1