accsum

accsum Commit Details

Date:2015-07-16 10:51:20 (2 years 9 months ago)
Author:John Gliksberg
Commit:31
Parents: 30
Message:fixed gateways + tests for YaSp
Changes:
M/sci_gateway/c/sci_accsum_fcompsum.c
M/tests/unit_tests/wilkinson.dia.ref
M/tests/unit_tests/priestx.dia.ref
M/sci_gateway/c/sci_accsum_fscs.c
M/tests/unit_tests/wilkinson.tst
M/sci_gateway/c/sci_accsum_fdcs.c

File differences

sci_gateway/c/sci_accsum_fcompsum.c
1313
1414
1515
16
1716
1817
1918
......
2221
2322
2423
25
24
2625
2726
2827
#include "machine.h"
#include "Scierror.h"
#include "stack-c.h"
#include "api_scilab.h"
#include "localization.h"
// s = accsum_fcompsum(x)
// [s,e] = accsum_fcompsum(x)
// returns the sum of x, with a compensated summation.
int sci_accsum_fcompsum (char * fname) {
int sci_accsum_fcompsum (char * fname, void* pvApiCtx) {
SciErr sciErr;
int *piAddr = NULL;
sci_gateway/c/sci_accsum_fscs.c
1313
1414
1515
16
1716
1817
1918
......
2221
2322
2423
25
24
2625
2726
2827
#include "machine.h"
#include "Scierror.h"
#include "stack-c.h"
#include "api_scilab.h"
#include "localization.h"
// s = accsum_fdcs(x)
// [s,e] = accsum_fdcs(x)
// returns the sum of x, with a simply compensated summation.
int sci_accsum_fscs (char * fname) {
int sci_accsum_fscs (char * fname, void* pvApiCtx) {
SciErr sciErr;
int *piAddr = NULL;
sci_gateway/c/sci_accsum_fdcs.c
1313
1414
1515
16
1716
1817
1918
......
2221
2322
2423
25
24
2625
2726
2827
#include "machine.h"
#include "Scierror.h"
#include "stack-c.h"
#include "api_scilab.h"
#include "localization.h"
// s = accsum_fdcs(x)
// [s,e] = accsum_fdcs(x)
// returns the sum of x, with a doubly compensated summation.
int sci_accsum_fdcs (char * fname) {
int sci_accsum_fdcs (char * fname, void* pvApiCtx) {
SciErr sciErr;
int *piAddr = NULL;
tests/unit_tests/wilkinson.tst
1414
1515
1616
17
17
1818
1919
x = accsum_wilkinson (3);
// Expected result
e = [1 , 1-%eps , 1-2*%eps , 1-2*%eps , 1-4*%eps , 1-4*%eps , 1-4*%eps , 1-4*%eps]';
assert_checkalmostequal(x,e,2*%eps);
assert_checkalmostequal(x,e,3*%eps);
tests/unit_tests/priestx.dia.ref
99
1010
1111
12
13
14
15
16
17
18
19
20
21
12
13
14
15
16
17
18
2219
2320
2421
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
x = accsum_priestx ( )
x =
10^15 *
18.014399
18.014399
- 9.0071993
- 9.0071993
- 9.0071993
- 9.0071993
x =
1.801D+16
1.801D+16
- 9.007D+15
- 9.007D+15
- 9.007D+15
- 9.007D+15
expected = [
18014398509481984;
18014398509481982;
tests/unit_tests/wilkinson.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Copyright (C) 2011 - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
//
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
// Example with r = 3
x = accsum_wilkinson (3);
// Expected result
e = [1 , 1-%eps , 1-2*%eps , 1-2*%eps , 1-4*%eps , 1-4*%eps , 1-4*%eps , 1-4*%eps]';
assert_checkalmostequal(x,e,2*%eps);
// Copyright (C) 2011 - Michael Baudin
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
//
// <-- JVM NOT MANDATORY -->
// <-- ENGLISH IMPOSED -->
// Example with r = 3
x = accsum_wilkinson (3);
// Expected result
e = [1 , 1-%eps , 1-2*%eps , 1-2*%eps , 1-4*%eps , 1-4*%eps , 1-4*%eps , 1-4*%eps]';
assert_checkalmostequal(x,e,3*%eps);

Archive Download the corresponding diff file

Revision: 31