|
| 1 | +package com.arrayfire; |
| 2 | + |
| 3 | +public class Arith extends Array { |
| 4 | + |
| 5 | + // Binary operations |
| 6 | + private native static long add(long a, long b); |
| 7 | + private native static long sub(long a, long b); |
| 8 | + private native static long mul(long a, long b); |
| 9 | + private native static long div(long a, long b); |
| 10 | + private native static long le (long a, long b); |
| 11 | + private native static long lt (long a, long b); |
| 12 | + private native static long ge (long a, long b); |
| 13 | + private native static long gt (long a, long b); |
| 14 | + private native static long eq (long a, long b); |
| 15 | + private native static long ne (long a, long b); |
| 16 | + //private native static long pow(long a, float b); |
| 17 | + |
| 18 | + // Scalar Binary operations |
| 19 | + private native static long addf(long a, float b); |
| 20 | + private native static long subf(long a, float b); |
| 21 | + private native static long mulf(long a, float b); |
| 22 | + private native static long divf(long a, float b); |
| 23 | + private native static long lef (long a, float b); |
| 24 | + private native static long ltf (long a, float b); |
| 25 | + private native static long gef (long a, float b); |
| 26 | + private native static long gtf (long a, float b); |
| 27 | + private native static long eqf (long a, float b); |
| 28 | + private native static long nef (long a, float b); |
| 29 | + private native static long powf(long a, float b); |
| 30 | + |
| 31 | + private native static long fsub(float a, long b); |
| 32 | + private native static long fdiv(float a, long b); |
| 33 | + private native static long fle (float a, long b); |
| 34 | + private native static long flt (float a, long b); |
| 35 | + private native static long fge (float a, long b); |
| 36 | + private native static long fgt (float a, long b); |
| 37 | + //private native static long fpow(long a, float b); |
| 38 | + |
| 39 | + // Unary operations |
| 40 | + private native static long sin (long a); |
| 41 | + private native static long cos (long a); |
| 42 | + private native static long tan (long a); |
| 43 | + private native static long asin (long a); |
| 44 | + private native static long acos (long a); |
| 45 | + private native static long atan (long a); |
| 46 | + private native static long sinh (long a); |
| 47 | + private native static long cosh (long a); |
| 48 | + private native static long tanh (long a); |
| 49 | + private native static long asinh(long a); |
| 50 | + private native static long acosh(long a); |
| 51 | + private native static long atanh(long a); |
| 52 | + private native static long exp (long a); |
| 53 | + private native static long log (long a); |
| 54 | + private native static long abs (long a); |
| 55 | + private native static long sqrt (long a); |
| 56 | + |
| 57 | + |
| 58 | + public static Array add(Array a, Array b) throws Exception { |
| 59 | + Array ret_val = new Array(); |
| 60 | + ret_val.ref = add(a.ref,b.ref); |
| 61 | + return ret_val; |
| 62 | + } |
| 63 | + |
| 64 | + public static Array sub(Array a, Array b) throws Exception { |
| 65 | + Array ret_val = new Array(); |
| 66 | + ret_val.ref = sub(a.ref,b.ref); |
| 67 | + return ret_val; |
| 68 | + } |
| 69 | + |
| 70 | + public static Array mul(Array a, Array b) throws Exception { |
| 71 | + Array ret_val = new Array(); |
| 72 | + ret_val.ref = mul(a.ref,b.ref); |
| 73 | + return ret_val; |
| 74 | + } |
| 75 | + |
| 76 | + public static Array div(Array a, Array b) throws Exception { |
| 77 | + Array ret_val = new Array(); |
| 78 | + ret_val.ref = div(a.ref,b.ref); |
| 79 | + return ret_val; |
| 80 | + } |
| 81 | + |
| 82 | + public static Array le(Array a, Array b) throws Exception { |
| 83 | + Array ret_val = new Array(); |
| 84 | + ret_val.ref = le(a.ref,b.ref); |
| 85 | + return ret_val; |
| 86 | + } |
| 87 | + |
| 88 | + public static Array lt(Array a, Array b) throws Exception { |
| 89 | + Array ret_val = new Array(); |
| 90 | + ret_val.ref = lt(a.ref,b.ref); |
| 91 | + return ret_val; |
| 92 | + } |
| 93 | + |
| 94 | + public static Array ge(Array a, Array b) throws Exception { |
| 95 | + Array ret_val = new Array(); |
| 96 | + ret_val.ref = ge(a.ref,b.ref); |
| 97 | + return ret_val; |
| 98 | + } |
| 99 | + |
| 100 | + public static Array gt(Array a, Array b) throws Exception { |
| 101 | + Array ret_val = new Array(); |
| 102 | + ret_val.ref = gt(a.ref,b.ref); |
| 103 | + return ret_val; |
| 104 | + } |
| 105 | + |
| 106 | + public static Array eq(Array a, Array b) throws Exception { |
| 107 | + Array ret_val = new Array(); |
| 108 | + ret_val.ref = eq(a.ref,b.ref); |
| 109 | + return ret_val; |
| 110 | + } |
| 111 | + |
| 112 | + public static Array ne(Array a, Array b) throws Exception { |
| 113 | + Array ret_val = new Array(); |
| 114 | + ret_val.ref = ne(a.ref,b.ref); |
| 115 | + return ret_val; |
| 116 | + } |
| 117 | + |
| 118 | + // Unary operations |
| 119 | + public static Array sin(Array a) throws Exception { |
| 120 | + Array ret_val = new Array(); |
| 121 | + ret_val.ref = sin(a.ref); |
| 122 | + return ret_val; |
| 123 | + } |
| 124 | + |
| 125 | + public static Array cos(Array a) throws Exception { |
| 126 | + Array ret_val = new Array(); |
| 127 | + ret_val.ref = cos(a.ref); |
| 128 | + return ret_val; |
| 129 | + } |
| 130 | + |
| 131 | + public static Array tan(Array a) throws Exception { |
| 132 | + Array ret_val = new Array(); |
| 133 | + ret_val.ref = tan(a.ref); |
| 134 | + return ret_val; |
| 135 | + } |
| 136 | + |
| 137 | + public static Array asin(Array a) throws Exception { |
| 138 | + Array ret_val = new Array(); |
| 139 | + ret_val.ref = asin(a.ref); |
| 140 | + return ret_val; |
| 141 | + } |
| 142 | + |
| 143 | + public static Array acos(Array a) throws Exception { |
| 144 | + Array ret_val = new Array(); |
| 145 | + ret_val.ref = acos(a.ref); |
| 146 | + return ret_val; |
| 147 | + } |
| 148 | + |
| 149 | + public static Array atan(Array a) throws Exception { |
| 150 | + Array ret_val = new Array(); |
| 151 | + ret_val.ref = atan(a.ref); |
| 152 | + return ret_val; |
| 153 | + } |
| 154 | + |
| 155 | + public static Array sinh(Array a) throws Exception { |
| 156 | + Array ret_val = new Array(); |
| 157 | + ret_val.ref = sinh(a.ref); |
| 158 | + return ret_val; |
| 159 | + } |
| 160 | + |
| 161 | + public static Array cosh(Array a) throws Exception { |
| 162 | + Array ret_val = new Array(); |
| 163 | + ret_val.ref = cosh(a.ref); |
| 164 | + return ret_val; |
| 165 | + } |
| 166 | + |
| 167 | + public static Array tanh(Array a) throws Exception { |
| 168 | + Array ret_val = new Array(); |
| 169 | + ret_val.ref = tanh(a.ref); |
| 170 | + return ret_val; |
| 171 | + } |
| 172 | + |
| 173 | + public static Array asinh(Array a) throws Exception { |
| 174 | + Array ret_val = new Array(); |
| 175 | + ret_val.ref = asinh(a.ref); |
| 176 | + return ret_val; |
| 177 | + } |
| 178 | + public static Array acosh(Array a) throws Exception { |
| 179 | + Array ret_val = new Array(); |
| 180 | + ret_val.ref = acosh(a.ref); |
| 181 | + return ret_val; |
| 182 | + } |
| 183 | + public static Array atanh(Array a) throws Exception { |
| 184 | + Array ret_val = new Array(); |
| 185 | + ret_val.ref = atanh(a.ref); |
| 186 | + return ret_val; |
| 187 | + } |
| 188 | + public static Array exp(Array a) throws Exception { |
| 189 | + Array ret_val = new Array(); |
| 190 | + ret_val.ref = exp(a.ref); |
| 191 | + return ret_val; |
| 192 | + } |
| 193 | + public static Array log(Array a) throws Exception { |
| 194 | + Array ret_val = new Array(); |
| 195 | + ret_val.ref = log(a.ref); |
| 196 | + return ret_val; |
| 197 | + } |
| 198 | + public static Array abs(Array a) throws Exception { |
| 199 | + Array ret_val = new Array(); |
| 200 | + ret_val.ref = abs(a.ref); |
| 201 | + return ret_val; |
| 202 | + } |
| 203 | + public static Array sqrt(Array a) throws Exception { |
| 204 | + Array ret_val = new Array(); |
| 205 | + ret_val.ref = sqrt(a.ref); |
| 206 | + return ret_val; |
| 207 | + } |
| 208 | + |
| 209 | + // Scalar operations |
| 210 | + public static Array add(Array a, float b) throws Exception { |
| 211 | + Array res = new Array(); |
| 212 | + res.ref = addf(a.ref,b); |
| 213 | + return res; |
| 214 | + } |
| 215 | + |
| 216 | + public static Array sub(Array a, float b) throws Exception { |
| 217 | + Array res = new Array(); |
| 218 | + res.ref = subf(a.ref,b); |
| 219 | + return res; |
| 220 | + } |
| 221 | + |
| 222 | + public static Array mul(Array a, float b) throws Exception { |
| 223 | + Array res = new Array(); |
| 224 | + res.ref = mulf(a.ref,b); |
| 225 | + return res; |
| 226 | + } |
| 227 | + |
| 228 | + public static Array div(Array a, float b) throws Exception { |
| 229 | + Array res = new Array(); |
| 230 | + res.ref = divf(a.ref,b); |
| 231 | + return res; |
| 232 | + } |
| 233 | + |
| 234 | + public static Array le(Array a, float b) throws Exception { |
| 235 | + Array res = new Array(); |
| 236 | + res.ref = lef(a.ref,b); |
| 237 | + return res; |
| 238 | + } |
| 239 | + |
| 240 | + public static Array lt(Array a, float b) throws Exception { |
| 241 | + Array res = new Array(); |
| 242 | + res.ref = ltf(a.ref,b); |
| 243 | + return res; |
| 244 | + } |
| 245 | + |
| 246 | + public static Array ge(Array a, float b) throws Exception { |
| 247 | + Array res = new Array(); |
| 248 | + res.ref = gef(a.ref,b); |
| 249 | + return res; |
| 250 | + } |
| 251 | + |
| 252 | + public static Array gt(Array a, float b) throws Exception { |
| 253 | + Array res = new Array(); |
| 254 | + res.ref = gtf(a.ref,b); |
| 255 | + return res; |
| 256 | + } |
| 257 | + |
| 258 | + public static Array eq(Array a, float b) throws Exception { |
| 259 | + Array res = new Array(); |
| 260 | + res.ref = eqf(a.ref,b); |
| 261 | + return res; |
| 262 | + } |
| 263 | + |
| 264 | + public static Array ne(Array a, float b) throws Exception { |
| 265 | + Array res = new Array(); |
| 266 | + res.ref = nef(a.ref,b); |
| 267 | + return res; |
| 268 | + } |
| 269 | + |
| 270 | + public static Array pow(Array a, float b) throws Exception { |
| 271 | + Array res = new Array(); |
| 272 | + res.ref = powf(a.ref,b); |
| 273 | + return res; |
| 274 | + } |
| 275 | + |
| 276 | + public static Array add(float a, Array b) throws Exception { |
| 277 | + Array res = new Array(); |
| 278 | + res.ref = addf(b.ref,a); |
| 279 | + return res; |
| 280 | + } |
| 281 | + |
| 282 | + public static Array sub(float a, Array b) throws Exception { |
| 283 | + Array res = new Array(); |
| 284 | + res.ref = fsub(a,b.ref); |
| 285 | + return res; |
| 286 | + } |
| 287 | + |
| 288 | + public static Array mul(float a, Array b) throws Exception { |
| 289 | + Array res = new Array(); |
| 290 | + res.ref = mulf(b.ref,a); |
| 291 | + return res; |
| 292 | + } |
| 293 | + |
| 294 | + public static Array div(float a, Array b) throws Exception { |
| 295 | + Array res = new Array(); |
| 296 | + res.ref = fdiv(a,b.ref); |
| 297 | + return res; |
| 298 | + } |
| 299 | + |
| 300 | + public static Array le(float a, Array b) throws Exception { |
| 301 | + Array res = new Array(); |
| 302 | + res.ref = fle(a,b.ref); |
| 303 | + return res; |
| 304 | + } |
| 305 | + |
| 306 | + public static Array lt(float a, Array b) throws Exception { |
| 307 | + Array res = new Array(); |
| 308 | + res.ref = flt(a,b.ref); |
| 309 | + return res; |
| 310 | + } |
| 311 | + |
| 312 | + public static Array ge(float a, Array b) throws Exception { |
| 313 | + Array res = new Array(); |
| 314 | + res.ref = fge(a,b.ref); |
| 315 | + return res; |
| 316 | + } |
| 317 | + |
| 318 | + public static Array gt(float a, Array b) throws Exception { |
| 319 | + Array res = new Array(); |
| 320 | + res.ref = fgt(a,b.ref); |
| 321 | + return res; |
| 322 | + } |
| 323 | + |
| 324 | +} |
0 commit comments