1 | /* ------------------ */ |
---|
2 | /* --- nrarith2.c --- */ |
---|
3 | /* ------------------ */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | * |
---|
9 | * Distributed under the Boost Software License, Version 1.0 |
---|
10 | * see accompanying file LICENSE.txt or copy it at |
---|
11 | * http://www.boost.org/LICENSE_1_0.txt |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <stddef.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <malloc.h> |
---|
18 | #include <math.h> // fabs |
---|
19 | |
---|
20 | #include "nrc_os_config.h" |
---|
21 | #include "mypredef.h" |
---|
22 | #include "nrtype.h" |
---|
23 | #include "nrdef.h" |
---|
24 | #include "nrmacro.h" |
---|
25 | #include "nrkernel.h" |
---|
26 | |
---|
27 | |
---|
28 | #undef addcnz_type_matrix |
---|
29 | #define addcnz_type_matrix(t) \ |
---|
30 | void short_name(t,addcnz_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \ |
---|
31 | { \ |
---|
32 | t * Xi; \ |
---|
33 | t * Yi; \ |
---|
34 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
35 | Xi = src[i]; \ |
---|
36 | Yi = dst[i]; \ |
---|
37 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
38 | if (Xi[j] != 0) { \ |
---|
39 | Yi[j] = Xi[j] + cte; \ |
---|
40 | } \ |
---|
41 | else { \ |
---|
42 | Yi[j] = Xi[j]; \ |
---|
43 | } \ |
---|
44 | } \ |
---|
45 | } \ |
---|
46 | } |
---|
47 | |
---|
48 | addcnz_type_matrix(int8_t); |
---|
49 | addcnz_type_matrix(uint8_t); |
---|
50 | addcnz_type_matrix(int16_t); |
---|
51 | addcnz_type_matrix(uint16_t); |
---|
52 | addcnz_type_matrix(int32_t); |
---|
53 | addcnz_type_matrix(uint32_t); |
---|
54 | addcnz_type_matrix(int64_t); |
---|
55 | addcnz_type_matrix(uint64_t); |
---|
56 | addcnz_type_matrix(float); |
---|
57 | addcnz_type_matrix(double); |
---|
58 | |
---|
59 | |
---|
60 | #undef addandc_type_matrix |
---|
61 | #define addandc_type_matrix(t) \ |
---|
62 | void short_name(t,addandc_,matrix)(t ** src, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t cte, t ** dst) \ |
---|
63 | { \ |
---|
64 | t * Xi; \ |
---|
65 | t * Yi; \ |
---|
66 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
67 | Xi = src[i]; \ |
---|
68 | Yi = dst[i]; \ |
---|
69 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
70 | if (Xi[j] != 0) { \ |
---|
71 | Yi[j] = Xi[j] + cte; \ |
---|
72 | } \ |
---|
73 | } \ |
---|
74 | } \ |
---|
75 | } |
---|
76 | |
---|
77 | addandc_type_matrix(int8_t); |
---|
78 | addandc_type_matrix(uint8_t); |
---|
79 | addandc_type_matrix(int16_t); |
---|
80 | addandc_type_matrix(uint16_t); |
---|
81 | addandc_type_matrix(int32_t); |
---|
82 | addandc_type_matrix(uint32_t); |
---|
83 | addandc_type_matrix(int64_t); |
---|
84 | addandc_type_matrix(uint64_t); |
---|
85 | addandc_type_matrix(float); |
---|
86 | addandc_type_matrix(double); |
---|
87 | |
---|
88 | |
---|
89 | #undef sum_type_matrix |
---|
90 | #define sum_type_matrix(t,rt) \ |
---|
91 | rt short_name(t,sum_,matrix)(t ** m, int32_t nrl, int32_t nrh,int32_t ncl, int32_t nch) \ |
---|
92 | { \ |
---|
93 | rt s = 0; \ |
---|
94 | t * Xi; \ |
---|
95 | for (int32_t i = nrl; i <= nrh; i++) { \ |
---|
96 | Xi = m[i]; \ |
---|
97 | for (int32_t j = ncl; j <= nch; j++) { \ |
---|
98 | s += Xi[j]; \ |
---|
99 | } \ |
---|
100 | } \ |
---|
101 | return s; \ |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | sum_type_matrix(int8_t, int32_t); |
---|
106 | sum_type_matrix(uint8_t, uint32_t); |
---|
107 | sum_type_matrix(int16_t, int32_t); |
---|
108 | sum_type_matrix(uint16_t, uint32_t); |
---|
109 | sum_type_matrix(int32_t, int64_t); |
---|
110 | sum_type_matrix(uint32_t, uint64_t); |
---|
111 | sum_type_matrix(int64_t, int64_t); |
---|
112 | sum_type_matrix(uint64_t, uint64_t); |
---|
113 | sum_type_matrix(float, float); |
---|
114 | sum_type_matrix(double, double); |
---|
115 | |
---|
116 | |
---|
117 | // Local Variables: |
---|
118 | // tab-width: 4 |
---|
119 | // c-basic-offset: 4 |
---|
120 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
121 | // indent-tabs-mode: nil |
---|
122 | // End: |
---|
123 | |
---|
124 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
125 | |
---|