function test_c99_complex; $ #include $ $ _Complex double zsum(_Complex double* zarray, int n) { $ int i; $ _Complex double sum = 0; $ for (i = 0; i < n; ++i) sum += zarray[i]; $ return sum; $ } zarray = rand(10,1) + 1i*rand(10,1); n = length(zarray); # dcomplex result = zsum(dcomplex[] zarray, int n); tassert(abs(result-sum(zarray)) < 1e-10*norm(zarray), 'C++ complex support'); # dcomplex cresult = conj(dcomplex result); tassert(conj(result) == cresult, 'C++ complex support (2)'); function tassert(pred, msg) if ~pred, fprintf('Failure: %s\n', msg); end