File: test_single.mw

package info (click to toggle)
mwrap 1.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 980 kB
  • sloc: cpp: 3,271; ansic: 856; makefile: 252; lex: 233; sh: 2
file content (63 lines) | stat: -rw-r--r-- 1,853 bytes parent folder | download | duplicates (4)
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
% test double and single precision, scalars and arrays, in mwrap.
% Barnett & Gimbutas 7/5/20-7/20/20.

% make as in Makefile,
% then pass-fail test in octave/matlab with:
% test_single.m

% the old non-pass-fail is here:
% test_single_humanreadable.m


% REAL======================================================

% scalar real.........

$ void add(double a, double b, double *c) { *c = a + b; }
@function c=add(a,b)
# add(double a, double b, output double[1]c);

$ void addf(float a, float b, float *c) { *c = a + b; }
@function c=addf(a,b)
# addf(float a, float b, output float[1]c);

% array real........

$ void arradd(double *a, double *b, double *c, int n)
$ { for (int i=0;i<n;++i) c[i] = a[i] + b[i]; }
@function c=arradd(a,b)
n = numel(a);
# arradd(double[n] a, double[n] b, output double[n]c, int n);

$ void arraddf(float *a, float *b, float *c, int n)
$ { for (int i=0;i<n;++i) c[i] = a[i] + b[i]; }
@function c=arraddf(a,b)
n = numel(a);
# arraddf(float[n] a, float[n] b, output float[n]c, int n);


% COMPLEX=========================================================

% scalar complex.........

$ void addz(dcomplex a, dcomplex b, dcomplex *c) { *c = a + b; }
@function c=addz(a,b)
# addz(dcomplex a, dcomplex b, output dcomplex[1]c);

$ void addc(fcomplex a, fcomplex b, fcomplex *c) { *c = a + b; }
@function c=addc(a,b)
# addc(fcomplex a, fcomplex b, output fcomplex[1]c);

% array complex ........

$ void arraddz(dcomplex *a, dcomplex *b, dcomplex *c, int n)
$ { for (int i=0;i<n;++i) c[i] = a[i] + b[i]; }
@function c=arraddz(a,b)
n = numel(a);
# arraddz(dcomplex[n] a, dcomplex[n] b, output dcomplex[n]c, int n);

$ void arraddc(fcomplex *a, fcomplex *b, fcomplex *c, int n)
$ { for (int i=0;i<n;++i) c[i] = a[i] + b[i]; }
@function c=arraddc(a,b)
n = numel(a);
# arraddc(fcomplex[n] a, fcomplex[n] b, output fcomplex[n]c, int n);