# accsum Commit Details

## File differences

help/en_US/accsum_priestx.xml
 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 64 65 66
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_priestxA difficult example for SCS by Priest.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ x = accsum_priestx ( )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a 6-by-1, matrix of doubles␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ "On properties of floating point arithmetics:␍␊ numerical stability and the cost of accurate computations"␍␊ Douglas Priest, 1992␍␊ p62␍␊ "What is the smallest n for which simply compensated␍␊ summation is not guaranteed to yield a result␍␊ with a small forward relative error in an arithmetic which␍␊ conforms to the IEEE 754 standard. The smallest known␍␊ to the author is ... Then the exact sum is 2, but the sum␍␊ computed by the SCS is 3."␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊
help/en_US/accsum_orderdynamic.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
 ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_orderdynamicTry to find an order which makes the sum perform bad/good.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_orderdynamic ( x , order )␊ ␊ ␊ ␊ Parametersx : a m-by-n, matrix of doublesorder : a 1-by-1 matrix of doubles, a positive integer, the order. order = 1 : search for the entry which makes the smallest |s+y(i)|, good for accuracy, order = 2 : search for the entry which makes the largest |s+y(i)|, bad for accuracys : a 1-by-1 matrix of doubles, the sum␊ ␊ Description␊ Try to find an order which makes the sum perform bad/good.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et alhttps://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img16.htm
help/en_US/accsum_compsum.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_compsumThe compensated sum of a matrix.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ [s,e] = accsum_compsum ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a n-by-m matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ e :␍␊ a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ Returns the sum of x.␍␊ Algorithm 4.4 in HFCC␍␊ Due to Knuth␍␊ No assumption on a , b␍␊ Assumes that Scilab uses round-to-nearest.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_compsumThe compensated sum of a matrix.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_compsum ( x )␊ [s,e] = accsum_compsum ( x )␊ ␊ ␊ ␊ Parametersx : a n-by-m matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ Returns s and e such that s+e is the sum of x.␊ Algorithm 4.4 in HFCC␊ Due to Knuth␊ No assumption on a , b␊ Assumes that Scilab uses round-to-nearest.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et al
help/en_US/accsum_dblcompsum.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_dblcompsumThe doubly compensated sum of a matrix.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ [s,e] = accsum_dblcompsum ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a n-by-m matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ e :␍␊ a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ Returns the sum of x.␍␊ Algorithm 4.2 in SNAA (Doubly Compensated Summation)␍␊ Due to Priest (and Kahan)␍␊ Assumes that Scilab uses round-to-nearest.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_dblcompsumThe doubly compensated sum of a matrix.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_dblcompsum ( x )␊ [s,e] = accsum_dblcompsum ( x )␊ ␊ ␊ ␊ Parametersx : a n-by-m matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ Returns the sum of x.␊ Algorithm 4.2 in SNAA (Doubly Compensated Summation)␊ Due to Priest (and Kahan)␊ Assumes that Scilab uses round-to-nearest.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et al
help/en_US/accsum_scs.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_scsA Self Compensated Sum algorithm␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ [s,e] = accsum_scs ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a m-by-n, matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ e :␍␊ a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ A Self Compensated Sum algorithm.␍␊ Uses accsum_fasttwosum.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_scsA Self Compensated Sum algorithm␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_scs ( x )␊ [s,e] = accsum_scs ( x )␊ ␊ ␊ ␊ Parametersx : a m-by-n, matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ A Self Compensated Sum algorithm.␊ Uses accsum_fasttwosum.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et alhttps://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htmhttps://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F
help/en_US/accsum_dcs.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_dcsA Doubly Self Compensated Sum algorithm␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ [s,e] = accsum_dcs ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a m-by-n, matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ e :␍␊ a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ A Doubly Self Compensated Sum algorithm.␍␊ Uses accsum_fasttwosum.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_dcsA Doubly Self Compensated Sum algorithm␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_dcs ( x )␊ [s,e] = accsum_dcs ( x )␊ ␊ ␊ ␊ Parametersx : a m-by-n, matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ A Doubly Self Compensated Sum algorithm.␊ Uses accsum_fasttwosum.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et alhttps://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htmhttps://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F
help/en_US/accsum_fcompsum.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_fcompsumThe compensated sum of a matrix.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ s = accsum_fcompsum ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a n-by-m matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ Returns the sum of x.␍␊ Algorithm 4.4 in HFCC␍␊ Due to Knuth␍␊ No assumption on a , b␍␊ Assumes that we uses round-to-nearest.␍␊ This is a fast implementation, based on compiled source code..␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010-2011␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_fcompsumThe compensated sum of a matrix.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_fcompsum ( x )␊ [s,e] = accsum_fcompsum ( x )␊ ␊ ␊ ␊ Parametersx : a n-by-m matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ Returns the sum of x.␊ Algorithm 4.4 in HFCC␊ Due to Knuth␊ No assumption on a , b␊ Assumes that we uses round-to-nearest.␊ This is a fast implementation, based on compiled source code..␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010-2011␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et al
help/en_US/pseudomacros/accsum_fcompsum.sci
 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 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
 // Copyright (C) 2010-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␍␊ ␍␊ function s = accsum_fcompsum ( x )␍␊ // The compensated sum of a matrix.␍␊ // ␍␊ // Calling Sequence␍␊ // s = accsum_fcompsum ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a n-by-m matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // Returns the sum of x.␍␊ // Algorithm 4.4 in HFCC␍␊ // Due to Knuth␍␊ // No assumption on a , b␍␊ // Assumes that we uses round-to-nearest.␍␊ // This is a fast implementation, based on compiled source code..␍␊ // ␍␊ // Examples␍␊ // s = accsum_fcompsum ( [2 1] ) // 3␍␊ // s = accsum_fcompsum ( [1 2] ) // 3␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // s = accsum_fcompsum ( [1 %eps/2 ] )␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // s = accsum_fcompsum ( [%eps/2 1] )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010-2011␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010-2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_fcompsum ( x )␊ // The compensated sum of a matrix.␊ // ␊ // Calling Sequence␊ // s = accsum_fcompsum ( x )␊ // [s,e] = accsum_fcompsum ( x )␊ // ␊ // Parameters␊ // x : a n-by-m matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // Returns the sum of x.␊ // Algorithm 4.4 in HFCC␊ // Due to Knuth␊ // No assumption on a , b␊ // Assumes that we uses round-to-nearest.␊ // This is a fast implementation, based on compiled source code..␊ // ␊ // Examples␊ // s = accsum_fcompsum ( [2 1] ) // 3␊ // s = accsum_fcompsum ( [1 2] ) // 3␊ // // is 1+(%eps/2) but is 1 without algo␊ // s = accsum_fcompsum ( [1 %eps/2 ] )␊ // // is 1+(%eps/2) but is 1 without algo␊ // s = accsum_fcompsum ( [%eps/2 1] )␊ //␊ // Authors␊ // Michael Baudin, 2010-2011␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ endfunction␊ ␊
help/en_US/pseudomacros/accsum_fscs.sci
 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 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
 // Copyright (C) 2010-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␍␊ ␍␊ function s = accsum_fscs ( x )␍␊ // A Self Compensated Sum algorithm␍␊ // ␍␊ // Calling Sequence␍␊ // s = accsum_fscs ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a m-by-n, matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // A Self Compensated Sum algorithm.␍␊ // Uses the fasttwosum algorithm.␍␊ // This is a fast implementation, based on compiled source code.␍␊ // ␍␊ // Examples␍␊ // s = accsum_fscs ( [2 1] ) // 3␍␊ // s = accsum_fscs ( [1 2] ) // 3␍␊ // x = accsum_wilkinson(10); size(x,"*")␍␊ // s = sum(x)␍␊ // s = accsum_fscs ( x )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010-2011␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010-2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_fscs ( x )␊ // A Self Compensated Sum algorithm␊ // ␊ // Calling Sequence␊ // s = accsum_fscs ( x )␊ // [s,e] = accsum_fscs ( x )␊ // ␊ // Parameters␊ // x : a m-by-n, matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // A Self Compensated Sum algorithm.␊ // Uses the fasttwosum algorithm.␊ // This is a fast implementation, based on compiled source code.␊ // ␊ // Examples␊ // s = accsum_fscs ( [2 1] ) // 3␊ // s = accsum_fscs ( [1 2] ) // 3␊ // x = accsum_wilkinson(10); size(x,"*")␊ // s = sum(x)␊ // s = accsum_fscs ( x )␊ //␊ // Authors␊ // Michael Baudin, 2010-2011␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␊ ␊ endfunction␊ ␊
help/en_US/pseudomacros/accsum_fdcs.sci
 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 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
 // Copyright (C) 2010-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␍␊ ␍␊ function s = accsum_fdcs ( x )␍␊ // A Doubly Self Compensated Sum algorithm␍␊ // ␍␊ // Calling Sequence␍␊ // s = accsum_fdcs ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a m-by-n, matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // A Doubly Self Compensated Sum algorithm.␍␊ // Uses the fasttwosum algorithm.␍␊ // This is a fast implementation, based on compiled source code.␍␊ // ␍␊ // Examples␍␊ // s = accsum_fdcs ( [2 1] ) // 3␍␊ // s = accsum_fdcs ( [1 2] ) // 3␍␊ // s = accsum_fdcs ( [2 1] ) // 3␍␊ // s = accsum_fdcs ( [1 2] ) // 3␍␊ // x = accsum_wilkinson(10); size(x,"*")␍␊ // s = sum(x)␍␊ // s = accsum_fdcs ( x )␍␊ // s = accsum_fdcs ( x )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010-2011␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010-2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_fdcs ( x )␊ // A Doubly Self Compensated Sum algorithm␊ // ␊ // Calling Sequence␊ // s = accsum_fdcs ( x )␊ // [s,e] = accsum_fdcs ( x )␊ // ␊ // Parameters␊ // x : a m-by-n, matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // A Doubly Self Compensated Sum algorithm.␊ // Uses the fasttwosum algorithm.␊ // This is a fast implementation, based on compiled source code.␊ // ␊ // Examples␊ // s = accsum_fdcs ( [2 1] ) // 3␊ // s = accsum_fdcs ( [1 2] ) // 3␊ // s = accsum_fdcs ( [2 1] ) // 3␊ // s = accsum_fdcs ( [1 2] ) // 3␊ // x = accsum_wilkinson(10); size(x,"*")␊ // s = sum(x)␊ // s = accsum_fdcs ( x )␊ // s = accsum_fdcs ( x )␊ //␊ // Authors␊ // Michael Baudin, 2010-2011␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␊ ␊ endfunction␊ ␊
help/en_US/accsum_fasttwosum.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_fasttwosumThe fast2sum sum of a and b.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ [s,t] = accsum_fasttwosum ( a , b )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ a :␍␊ a 1-by-1 matrix of doubles␍␊ b :␍␊ a 1-by-1 matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ t :␍␊ a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ Returns the sum of a and b␍␊ so that a + b = s + t exactly.␍␊ where s contains the highest significant digits␍␊ and t the lowest significant digits.␍␊ ␍␊ ␍␊ Assumes that |a|>=|b|. If not, the arguments are switched.␍␊ ␍␊ ␍␊ Algorithm 4.3 in HFCC␍␊ Due to Dekker (and Kahan)␍␊ Assumes that Scilab uses round-to-nearest.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_fasttwosumThe fast2sum sum of a and b.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_fasttwosum ( a , b )␊ [s,t] = accsum_fasttwosum ( a , b )␊ ␊ ␊ ␊ Parametersa : a 1-by-1 matrix of doublesb : a 1-by-1 matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sumt : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ Returns the sum of a and b␊ so that a + b = s + t exactly.␊ where s contains the highest significant digits␊ and t the lowest significant digits.␊ ␊ Assumes that |a|>=|b|. If not, the arguments are switched.␊ ␊ Algorithm 4.3 in HFCC␊ Due to Dekker (and Kahan)␊ Assumes that Scilab uses round-to-nearest.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et al
help/en_US/accsum_fscs.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_fscsA Self Compensated Sum algorithm␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ s = accsum_fscs ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a m-by-n, matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ A Self Compensated Sum algorithm.␍␊ Uses the fasttwosum algorithm.␍␊ This is a fast implementation, based on compiled source code.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010-2011␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_fscsA Self Compensated Sum algorithm␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_fscs ( x )␊ [s,e] = accsum_fscs ( x )␊ ␊ ␊ ␊ Parametersx : a m-by-n, matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ A Self Compensated Sum algorithm.␊ Uses the fasttwosum algorithm.␊ This is a fast implementation, based on compiled source code.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010-2011␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et alhttps://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htmhttps://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F
help/en_US/accsum_twosum.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_twosumThe twosum sum of a and b.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ [s,t] = accsum_twosum ( a , b )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ a :␍␊ a 1-by-1 matrix of doubles␍␊ b :␍␊ a 1-by-1 matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ t :␍␊ a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ Returns the sum of a and b␍␊ so that a + b = s + t exactly.␍␊ where s contains the highest significant digits␍␊ and t the lowest significant digits.␍␊ Algorithm 4.4 in HFCC␍␊ Due to Knuth␍␊ No assumption on a , b␍␊ Assumes that Scilab uses round-to-nearest.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_twosumThe twosum sum of a and b.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_twosum ( a , b )␊ [s,t] = accsum_twosum ( a , b )␊ ␊ ␊ ␊ Parametersa : a 1-by-1 matrix of doublesb : a 1-by-1 matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sumt : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ Returns the sum of a and b␊ so that a + b = s + t exactly.␊ where s contains the highest significant digits␊ and t the lowest significant digits.␊ Algorithm 4.4 in HFCC␊ Due to Knuth␊ No assumption on a , b␊ Assumes that Scilab uses round-to-nearest.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et al
help/en_US/accsum_fdcs.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_fdcsA Doubly Self Compensated Sum algorithm␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ s = accsum_fdcs ( x )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a m-by-n, matrix of doubles␍␊ s :␍␊ a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ A Doubly Self Compensated Sum algorithm.␍␊ Uses the fasttwosum algorithm.␍␊ This is a fast implementation, based on compiled source code.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Authors␍␊ ␍␊ Michael Baudin, 2010-2011␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Bibliography␍␊ "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ "Handbook of Floating Point Computations", Muller et al␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ ␍␊ ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_fdcsA Doubly Self Compensated Sum algorithm␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_fdcs ( x )␊ [s,e] = accsum_fdcs ( x )␊ ␊ ␊ ␊ Parametersx : a m-by-n, matrix of doubless : a 1-by-1 matrix of doubles, the highest significant digits of the sume : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ ␊ Description␊ A Doubly Self Compensated Sum algorithm.␊ Uses the fasttwosum algorithm.␊ This is a fast implementation, based on compiled source code.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010-2011␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et alhttps://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htmhttps://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F
help/en_US/support/accsum_priestx.xml
 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 64 65 66
 ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ accsum_priestxA difficult example for SCS by Priest.␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Calling Sequence␍␊ ␍␊ x = accsum_priestx ( )␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Parameters␍␊ ␍␊ x :␍␊ a 6-by-1, matrix of doubles␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Description␍␊ ␍␊ "On properties of floating point arithmetics:␍␊ numerical stability and the cost of accurate computations"␍␊ Douglas Priest, 1992␍␊ p62␍␊ "What is the smallest n for which simply compensated␍␊ summation is not guaranteed to yield a result␍␊ with a small forward relative error in an arithmetic which␍␊ conforms to the IEEE 754 standard. The smallest known␍␊ to the author is ... Then the exact sum is 2, but the sum␍␊ computed by the SCS is 3."␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ ␍␊ Examples␍␊ ␍␊ ␍␊ ␍␊
help/en_US/support/accsum_orderdynamic.xml
 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
 ␊ ␊ ␊ ␊ ␊ ␊ ␊ accsum_orderdynamicTry to find an order which makes the sum perform bad/good.␊ ␊ ␊ ␊ Calling Sequence␊ s = accsum_orderdynamic ( x , order )␊ ␊ ␊ ␊ Parametersx : a m-by-n, matrix of doublesorder : a 1-by-1 matrix of doubles, a positive integer, the order. order = 1 : search for the entry which makes the smallest |s+y(i)|, good for accuracy, order = 2 : search for the entry which makes the largest |s+y(i)|, bad for accuracys : a 1-by-1 matrix of doubles, the sum␊ ␊ Description␊ Try to find an order which makes the sum perform bad/good.␊ ␊ ␊ Examples␊ ␊ AuthorsMichael Baudin, 2010␊ ␊ Bibliography"Stability and numerical accuracy of algorithms", Nicolas Higham"Handbook of Floating Point Computations", Muller et alhttps://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img16.htm
sci_gateway/c/sci_accsum_fscs.c
 1 1 2 2 3 3 4 4 5 ... ... 18 19 19 20 20 21 21 22 23 24 22 25 23 26 24 27 ... ... 27 30 28 31 29 32 30 31 33 34 35 32 36 33 37 34 38 35 39 36 40 ... ... 68 72 69 73 70 74 71 72 73 74 75 76 77 78 79 80 75 81 82 76 83 77 84 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 85 104 86 105 87 106
 // Copyright (C) 2010 - Michael Baudin␊ // Copyright (C) 2010-2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ #include "accsum.h"␊ ␊ // s = accsum_fscs(x) returns the sum of x, with a simply compensated summation.␊ // 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) {␊ ␊ ␉SciErr sciErr;␊ ␉int rowsX,colsX;␊ ␉double* lX = NULL;␊ ␉int iComplex = 0;␊ ␉double* lS = NULL;␊ ␉int i;␊ double s;␊ double e;␊ ␊ ␉int minlhs=1, minrhs=1, maxlhs=1, maxrhs=1;␊ ␉int minlhs=1, minrhs=1, maxlhs=2, maxrhs=1;␊ ␊ ␉CheckRhs(minrhs,maxrhs) ;␊ ␉CheckLhs(minlhs,maxlhs) ;␊ ␉␉return 0;␊ ␉}␊ ␉//␊ ␉// Create s␊ ␉//␊ ␉sciErr = allocMatrixOfDouble(pvApiCtx,Rhs+1, 1, 1, &lS);␊ ␉if(sciErr.iErr)␊ ␉{␊ ␉␉printError(&sciErr, 0);␊ ␉␉return 0;␊ ␉}␊ ␉//␊ ␉// Perform the sum␊ ␉//␊ accsum_fscs(lX, rowsX*colsX, lS);␊ accsum_fscs(lX, rowsX*colsX, &s, &e);␊ ␊ ␉LhsVar(1) = Rhs+1;␊ //␊ // Set LHS␊ if ( Lhs>=1 )␊ {␊ //␊ // Create s␊ sciErr = createMatrixOfDouble(pvApiCtx,Rhs+1, 1, 1, &s);␊ if(sciErr.iErr)␊ {␊ printError(&sciErr, 0);␊ return 0;␊ }␊ LhsVar(1) = Rhs+1;␊ } ␊ if ( Lhs==2 )␊ {␊ //␊ // Create e␊ sciErr = createMatrixOfDouble(pvApiCtx,Rhs+2, 1, 1, &e);␊ if(sciErr.iErr)␊ {␊ printError(&sciErr, 0);␊ return 0;␊ }␊ LhsVar(2) = Rhs+2;␊ }␊ ␊ ␉return(0);␊ ␊
sci_gateway/c/sci_accsum_fdcs.c
 1 1 2 2 3 3 4 4 5 ... ... 18 19 19 20 20 21 21 22 23 24 22 25 23 26 24 27 ... ... 27 30 28 31 29 32 30 31 33 34 35 32 36 33 37 34 38 35 39 36 40 ... ... 68 72 69 73 70 74 71 72 73 74 75 76 77 78 79 80 75 81 82 76 83 77 84 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 85 104 86 105 87 106
 // Copyright (C) 2010 - Michael Baudin␊ // Copyright (C) 2010-2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ #include "accsum.h"␊ ␊ // s = accsum_fdcs(x) returns the sum of x, with a doubly compensated summation.␊ // 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) {␊ ␊ ␉SciErr sciErr;␊ ␉int rowsX,colsX;␊ ␉double* lX = NULL;␊ ␉int iComplex = 0;␊ ␉double* lS = NULL;␊ ␉int i;␊ double s;␊ double e;␊ ␊ ␉int minlhs=1, minrhs=1, maxlhs=1, maxrhs=1;␊ ␉int minlhs=1, minrhs=1, maxlhs=2, maxrhs=1;␊ ␊ ␉CheckRhs(minrhs,maxrhs) ;␊ ␉CheckLhs(minlhs,maxlhs) ;␊ ␉␉return 0;␊ ␉}␊ ␉//␊ ␉// Create s␊ ␉//␊ ␉sciErr = allocMatrixOfDouble(pvApiCtx,Rhs+1, 1, 1, &lS);␊ ␉if(sciErr.iErr)␊ ␉{␊ ␉␉printError(&sciErr, 0);␊ ␉␉return 0;␊ ␉}␊ ␉//␊ ␉// Perform the sum␊ ␉//␊ accsum_fdcs(lX, rowsX*colsX, lS);␊ accsum_fdcs(lX, rowsX*colsX, &s, &e);␊ ␊ ␉LhsVar(1) = Rhs+1;␊ //␊ // Set LHS␊ if ( Lhs>=1 )␊ {␊ //␊ // Create s␊ sciErr = createMatrixOfDouble(pvApiCtx,Rhs+1, 1, 1, &s);␊ if(sciErr.iErr)␊ {␊ printError(&sciErr, 0);␊ return 0;␊ }␊ LhsVar(1) = Rhs+1;␊ } ␊ if ( Lhs==2 )␊ {␊ //␊ // Create e␊ sciErr = createMatrixOfDouble(pvApiCtx,Rhs+2, 1, 1, &e);␊ if(sciErr.iErr)␊ {␊ printError(&sciErr, 0);␊ return 0;␊ }␊ LhsVar(2) = Rhs+2;␊ }␊ ␊ ␉return(0);␊ ␊
sci_gateway/c/sci_accsum_fcompsum.c
 1 1 2 2 3 3 4 4 5 ... ... 18 19 19 20 20 21 21 22 23 24 22 25 23 26 24 27 ... ... 27 30 28 31 29 32 30 31 33 34 35 32 36 33 37 34 38 35 39 36 40 ... ... 68 72 69 73 70 74 71 72 73 74 75 76 77 78 79 80 75 81 76 82 83 84 85 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 86 104 87 88 105 89 106
 // Copyright (C) 2010 - Michael Baudin␊ // Copyright (C) 2010-2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ #include "accsum.h"␊ ␊ // s = accsum_fcompsum(x) returns the sum of x, with a compensated summation.␊ // s = accsum_fcompsum(x) ␊ // [s,e] = accsum_fcompsum(x) ␊ // returns the sum of x, with a compensated summation.␊ int sci_accsum_fcompsum (char * fname) {␊ ␊ ␉SciErr sciErr;␊ ␉int rowsX,colsX;␊ ␉double* lX = NULL;␊ ␉int iComplex = 0;␊ ␉double* lS = NULL;␊ ␉int i;␊ double s;␊ double e;␊ ␊ ␉int minlhs=1, minrhs=1, maxlhs=1, maxrhs=1;␊ ␉int minlhs=1, minrhs=1, maxlhs=2, maxrhs=1;␊ ␊ ␉CheckRhs(minrhs,maxrhs) ;␊ ␉CheckLhs(minlhs,maxlhs) ;␊ ␉␉return 0;␊ ␉}␊ ␉//␊ ␉// Create s␊ ␉//␊ ␉sciErr = allocMatrixOfDouble(pvApiCtx,Rhs+1, 1, 1, &lS);␊ ␉if(sciErr.iErr)␊ ␉{␊ ␉␉printError(&sciErr, 0);␊ ␉␉return 0;␊ ␉}␊ ␉//␊ ␉// Perform the sum␊ ␉//␊ accsum_fcompsum(lX, rowsX*colsX, lS);␊ ␊ ␉LhsVar(1) = Rhs+1;␊ ␊ accsum_fcompsum(lX, rowsX*colsX, &s, &e);␊ //␊ // Set LHS␊ if ( Lhs>=1 )␊ {␊ //␊ // Create s␊ sciErr = createMatrixOfDouble(pvApiCtx,Rhs+1, 1, 1, &s);␊ if(sciErr.iErr)␊ {␊ printError(&sciErr, 0);␊ return 0;␊ }␊ LhsVar(1) = Rhs+1;␊ } ␊ if ( Lhs==2 )␊ {␊ //␊ // Create e␊ sciErr = createMatrixOfDouble(pvApiCtx,Rhs+2, 1, 1, &e);␊ if(sciErr.iErr)␊ {␊ printError(&sciErr, 0);␊ return 0;␊ }␊ LhsVar(2) = Rhs+2;␊ }␊ ␉return(0);␊ ␊ }␊ ␊
tests/unit_tests/fscs.tst
 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
 // Copyright (C) 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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 -->␊ ␊ [s,e] = accsum_fscs ( [2 1] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fscs ( [1 2] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fscs ( [2 1] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fscs ( [1 2] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ x = accsum_wilkinson(10);␊ [s,e] = accsum_fscs ( x );␊ assert_checkalmostequal(s,1024,1.e-12);␊ assert_checkalmostequal(e,-3.786e-14,[],1.e-10);␊ ␊
tests/unit_tests/fdcs.tst
 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
 // Copyright (C) 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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 -->␊ ␊ [s,e] = accsum_fdcs ( [2 1] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fdcs ( [1 2] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fdcs ( [2 1] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fdcs ( [1 2] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ x = accsum_wilkinson(10);␊ [s,e] = accsum_fdcs ( x );␊ assert_checkalmostequal(s,1024,1.e-12);␊ assert_checkalmostequal(e,-3.786e-14,[],1.e-10);␊ ␊
tests/unit_tests/fcompsum.tst
 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
 // Copyright (C) 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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 -->␊ ␊ [s,e] = accsum_fcompsum ( [2 1] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fcompsum ( [1 2] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fcompsum ( [2 1] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ [s,e] = accsum_fcompsum ( [1 2] );␊ assert_checkequal(s,3);␊ assert_checkequal(e,0);␊ //␊ x = accsum_wilkinson(10);␊ [s,e] = accsum_fcompsum ( x );␊ assert_checkalmostequal(s,1024,1.e-12);␊ assert_checkalmostequal(e,-3.786e-14,[],1.e-10);␊ ␊
macros/accsum_straight.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function s = accsum_straight ( x )␍␊ // The straightforward sum of a matrix.␍␊ // ␍␊ // Calling Sequence␍␊ // s = accsum_straight ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a n-by-m matrix of doubles␍␊ // s : a 1-by-1, matrix of doubles, the sum␍␊ // ␍␊ // Description␍␊ // Computes the sum.␍␊ //␍␊ // Uses an unvectorized loop. ␍␊ // This is a slow algorithm, used for comparison purposes ␍␊ // only.␍␊ //␍␊ // Caution!␍␊ // This function may not return the same ␍␊ // value as the "sum" function of Scilab!␍␊ // This is because the Intel MKL or ATLAS may ␍␊ // reorder the data, processing it block by block␍␊ // ␍␊ // Examples␍␊ // x = 1:10;␍␊ // accsum_straight(x)␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ n = size(x,"*")␍␊ s = 0␍␊ for i = 1 : n␍␊ s = s + x(i)␍␊ end␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function s = accsum_straight ( x )␊ // The straightforward sum of a matrix.␊ // ␊ // Calling Sequence␊ // s = accsum_straight ( x )␊ // ␊ // Parameters␊ // x : a n-by-m matrix of doubles␊ // s : a 1-by-1, matrix of doubles, the sum␊ // ␊ // Description␊ // Computes the sum.␊ //␊ // Uses an unvectorized loop. ␊ // This is a slow algorithm, used for comparison purposes ␊ // only.␊ //␊ // Caution!␊ // This function may not return the same ␊ // value as the "sum" function of Scilab!␊ // This is because the Intel MKL or ATLAS may ␊ // reorder the data, processing it block by block␊ // ␊ // Examples␊ // x = 1:10;␊ // accsum_straight(x)␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ n = size(x,"*")␊ s = 0␊ for i = 1 : n␊ s = s + x(i)␊ end␊ endfunction␊ ␊
macros/accsum_scs.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function [s,e] = accsum_scs ( x )␍␊ // A Self Compensated Sum algorithm␍␊ // ␍␊ // Calling Sequence␍␊ // [s,e] = accsum_scs ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a m-by-n, matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // A Self Compensated Sum algorithm.␍␊ // Uses accsum_fasttwosum.␍␊ // ␍␊ // Examples␍␊ // [s,e] = accsum_scs ( [2 1] ) // 3␍␊ // [s,e] = accsum_scs ( [1 2] ) // 3␍␊ // [s,e] = accsum_DCS ( [2 1] ) // 3␍␊ // [s,e] = accsum_DCS ( [1 2] ) // 3␍␊ // x = accsum_wilkinson(10); size(x,"*")␍␊ // s = sum(x)␍␊ // [s,e] = accsum_scs ( x )␍␊ // [s,e] = accsum_DCS ( x )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ s = 0␍␊ e = 0␍␊ n = size(x,"*")␍␊ for i = 1 : n␍␊ [s,e] = accsum_fasttwosum ( s , x(i) + e )␍␊ end␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_scs ( x )␊ // A Self Compensated Sum algorithm␊ // ␊ // Calling Sequence␊ // s = accsum_scs ( x )␊ // [s,e] = accsum_scs ( x )␊ // ␊ // Parameters␊ // x : a m-by-n, matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // A Self Compensated Sum algorithm.␊ // Uses accsum_fasttwosum.␊ // ␊ // Examples␊ // [s,e] = accsum_scs ( [2 1] ) // 3␊ // [s,e] = accsum_scs ( [1 2] ) // 3␊ // [s,e] = accsum_DCS ( [2 1] ) // 3␊ // [s,e] = accsum_DCS ( [1 2] ) // 3␊ // x = accsum_wilkinson(10); size(x,"*")␊ // s = sum(x)␊ // [s,e] = accsum_scs ( x )␊ // [s,e] = accsum_DCS ( x )␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␊ ␊ s = 0␊ e = 0␊ n = size(x,"*")␊ for i = 1 : n␊ [s,e] = accsum_fasttwosum ( s , x(i) + e )␊ end␊ endfunction␊ ␊
macros/accsum_shuffle.sci
 1 1 2 2 3 3 4 4 5
 // Copyright (C) 2010 - Michael Baudin␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊
macros/accsum_priestx.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function x = accsum_priestx ( )␍␊ // A difficult example for SCS by Priest.␍␊ // ␍␊ // Calling Sequence␍␊ // x = accsum_priestx ( )␍␊ // ␍␊ // Parameters␍␊ // x : a 6-by-1, matrix of doubles␍␊ // ␍␊ // Description␍␊ // "On properties of floating point arithmetics: ␍␊ // numerical stability and the cost of accurate computations"␍␊ // Douglas Priest, 1992␍␊ // p62␍␊ // "What is the smallest n for which simply compensated␍␊ // summation is not guaranteed to yield a result␍␊ // with a small forward relative error in an arithmetic which␍␊ // conforms to the IEEE 754 standard. The smallest known␍␊ // to the author is ... Then the exact sum is 2, but the sum␍␊ // computed by the SCS is 3."␍␊ // ␍␊ // Examples␍␊ // x = accsum_priestx ( )␍␊ // [s,e] = accsum_SCS ( x ) // = 3 + 0␍␊ // [s,e] = accsum_DCS ( x ) // = 2 + 0␍␊ ␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ // "On properties of floating point arithmetics: numerical stability and the cost of accurate computations", Douglas Priest, 1992␍␊ ␍␊ t = 53␍␊ x(1) = 2^(t+1)␍␊ x(2) = 2^(t+1) - 2␍␊ x(3:6) = -(2^t - 1)␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function x = accsum_priestx ( )␊ // A difficult example for SCS by Priest.␊ // ␊ // Calling Sequence␊ // x = accsum_priestx ( )␊ // ␊ // Parameters␊ // x : a 6-by-1, matrix of doubles␊ // ␊ // Description␊ // "On properties of floating point arithmetics: ␊ // numerical stability and the cost of accurate computations"␊ // Douglas Priest, 1992␊ // p62␊ // "What is the smallest n for which simply compensated␊ // summation is not guaranteed to yield a result␊ // with a small forward relative error in an arithmetic which␊ // conforms to the IEEE 754 standard. The smallest known␊ // to the author is ... Then the exact sum is 2, but the sum␊ // computed by the SCS is 3."␊ // ␊ // Examples␊ // x = accsum_priestx ( )␊ // [s,e] = accsum_SCS ( x ) // = 3 + 0␊ // [s,e] = accsum_DCS ( x ) // = 2 + 0␊ ␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ // "On properties of floating point arithmetics: numerical stability and the cost of accurate computations", Douglas Priest, 1992␊ ␊ t = 53␊ x(1) = 2^(t+1)␊ x(2) = 2^(t+1) - 2␊ x(3:6) = -(2^t - 1)␊ endfunction␊ ␊
macros/accsum_twosum.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function [s,t] = accsum_twosum ( a , b )␍␊ // The twosum sum of a and b.␍␊ // ␍␊ // Calling Sequence␍␊ // [s,t] = accsum_twosum ( a , b )␍␊ // ␍␊ // Parameters␍␊ // a : a 1-by-1 matrix of doubles␍␊ // b : a 1-by-1 matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // t : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // Returns the sum of a and b␍␊ // so that a + b = s + t exactly.␍␊ // where s contains the highest significant digits␍␊ // and t the lowest significant digits.␍␊ // Algorithm 4.4 in HFCC␍␊ // Due to Knuth␍␊ // No assumption on a , b␍␊ // Assumes that Scilab uses round-to-nearest.␍␊ // ␍␊ // Examples␍␊ // [s,t] = accsum_twosum ( 2 , 1 ) // 3␍␊ // [s,t] = accsum_twosum ( 1 , 2 ) // 3␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // [s,t] = accsum_twosum ( 1 , %eps/2 ) ␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // [s,t] = accsum_twosum ( %eps/2 , 1 ) ␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ s = a + b␍␊ ap = s - b␍␊ bp = s - ap␍␊ da = a - ap␍␊ db = b - bp␍␊ t = da + db␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,t] = accsum_twosum ( a , b )␊ // The twosum sum of a and b.␊ // ␊ // Calling Sequence␊ // s = accsum_twosum ( a , b )␊ // [s,t] = accsum_twosum ( a , b )␊ // ␊ // Parameters␊ // a : a 1-by-1 matrix of doubles␊ // b : a 1-by-1 matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // t : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // Returns the sum of a and b␊ // so that a + b = s + t exactly.␊ // where s contains the highest significant digits␊ // and t the lowest significant digits.␊ // Algorithm 4.4 in HFCC␊ // Due to Knuth␊ // No assumption on a , b␊ // Assumes that Scilab uses round-to-nearest.␊ // ␊ // Examples␊ // [s,t] = accsum_twosum ( 2 , 1 ) // 3␊ // [s,t] = accsum_twosum ( 1 , 2 ) // 3␊ // // is 1+(%eps/2) but is 1 without algo␊ // [s,t] = accsum_twosum ( 1 , %eps/2 ) ␊ // // is 1+(%eps/2) but is 1 without algo␊ // [s,t] = accsum_twosum ( %eps/2 , 1 ) ␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ s = a + b␊ ap = s - b␊ bp = s - ap␊ da = a - ap␊ db = b - bp␊ t = da + db␊ endfunction␊ ␊
macros/accsum_dblcompsum.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function [s,e] = accsum_dblcompsum ( x )␍␊ // The doubly compensated sum of a matrix.␍␊ // ␍␊ // Calling Sequence␍␊ // [s,e] = accsum_dblcompsum ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a n-by-m matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // Returns the sum of x.␍␊ // Algorithm 4.2 in SNAA (Doubly Compensated Summation)␍␊ // Due to Priest (and Kahan)␍␊ // Assumes that Scilab uses round-to-nearest.␍␊ // ␍␊ // Examples␍␊ // [s,e] = accsum_dblcompsum ( [2 1] ) // 3␍␊ // [s,e] = accsum_dblcompsum ( [1 2] ) // 3␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // [s,e] = accsum_dblcompsum ( [1 %eps/2 ] )␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // [s,e] = accsum_dblcompsum ( [%eps/2 1] )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ // Sort x in decreasing magnitude order.␍␊ [B,k] = gsort(abs(x))␍␊ x = x(k)␍␊ // Perform the sum␍␊ s = x(1)␍␊ e = 0␍␊ n = size(x,"*")␍␊ for i = 2 : n␍␊ y = e + x(i)␍␊ u = x(i) - (y - e)␍␊ t = y + s␍␊ v = y - (t - s)␍␊ z = u + v␍␊ s = t + z␍␊ e = z - (s - t)␍␊ end␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_dblcompsum ( x )␊ // The doubly compensated sum of a matrix.␊ // ␊ // Calling Sequence␊ // s = accsum_dblcompsum ( x )␊ // [s,e] = accsum_dblcompsum ( x )␊ // ␊ // Parameters␊ // x : a n-by-m matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // Returns the sum of x.␊ // Algorithm 4.2 in SNAA (Doubly Compensated Summation)␊ // Due to Priest (and Kahan)␊ // Assumes that Scilab uses round-to-nearest.␊ // ␊ // Examples␊ // [s,e] = accsum_dblcompsum ( [2 1] ) // 3␊ // [s,e] = accsum_dblcompsum ( [1 2] ) // 3␊ // // is 1+(%eps/2) but is 1 without algo␊ // [s,e] = accsum_dblcompsum ( [1 %eps/2 ] )␊ // // is 1+(%eps/2) but is 1 without algo␊ // [s,e] = accsum_dblcompsum ( [%eps/2 1] )␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ // Sort x in decreasing magnitude order.␊ [B,k] = gsort(abs(x))␊ x = x(k)␊ // Perform the sum␊ s = x(1)␊ e = 0␊ n = size(x,"*")␊ for i = 2 : n␊ y = e + x(i)␊ u = x(i) - (y - e)␊ t = y + s␊ v = y - (t - s)␊ z = u + v␊ s = t + z␊ e = z - (s - t)␊ end␊ endfunction␊ ␊
macros/accsum_sumcond.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function [s,c] = accsum_sumcond ( x)␍␊ // Condition number of the sum function.␍␊ // ␍␊ // Calling Sequence␍␊ // x = accsum_sumcond ( )␍␊ // ␍␊ // Parameters␍␊ // x : a m-by-n, matrix of doubles␍␊ // s : a 1-by-1, matrix of doubles, the sum␍␊ // c : a 1-by-1, matrix of doubles, the condition number␍␊ // ␍␊ // Description␍␊ // Condition number of the sum function.␍␊ // ␍␊ // Examples␍␊ // // A straightforward example of an ill-conditionned data for the sum.␍␊ // xl = 10^(1:15);␍␊ // x = [-xl xl+0.1];␍␊ // sum(x)␍␊ // [s,c] = accsum_sumcond(x)␍␊ // for o = 1 : 8␍␊ // xo = accsum_order ( x , o );␍␊ // [s,e] = accsum_DCS ( xo );␍␊ // disp([o s e])␍␊ // end␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ s = sum(x)␍␊ varf = sum(abs(x))␍␊ c = varf / abs(s)␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,c] = accsum_sumcond ( x )␊ // Condition number of the sum function.␊ // ␊ // Calling Sequence␊ // s = accsum_sumcond ( x )␊ // [s,c] = accsum_sumcond ( x )␊ // ␊ // Parameters␊ // x : a m-by-n, matrix of doubles␊ // s : a 1-by-1, matrix of doubles, the sum␊ // c : a 1-by-1, matrix of doubles, the condition number␊ // ␊ // Description␊ // Condition number of the sum function.␊ // ␊ // Examples␊ // // A straightforward example of an ill-conditionned data for the sum.␊ // xl = 10^(1:15);␊ // x = [-xl xl+0.1];␊ // sum(x)␊ // [s,c] = accsum_sumcond(x)␊ // for o = 1 : 8␊ // xo = accsum_order ( x , o );␊ // [s,e] = accsum_DCS ( xo );␊ // disp([o s e])␊ // end␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ s = sum(x)␊ varf = sum(abs(x))␊ c = varf / abs(s)␊ endfunction␊ ␊
macros/accsum_dcs.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function [s,e] = accsum_dcs ( x )␍␊ // A Doubly Self Compensated Sum algorithm␍␊ // ␍␊ // Calling Sequence␍␊ // [s,e] = accsum_dcs ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a m-by-n, matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // A Doubly Self Compensated Sum algorithm.␍␊ // Uses accsum_fasttwosum.␍␊ // ␍␊ // Examples␍␊ // [s,e] = accsum_dcs ( [2 1] ) // 3␍␊ // [s,e] = accsum_dcs ( [1 2] ) // 3␍␊ // [s,e] = accsum_dcs ( [2 1] ) // 3␍␊ // [s,e] = accsum_dcs ( [1 2] ) // 3␍␊ // x = accsum_wilkinson(10); size(x,"*")␍␊ // s = sum(x)␍␊ // [s,e] = accsum_dcs ( x )␍␊ // [s,e] = accsum_dcs ( x )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␍␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␍␊ ␍␊ s = 0␍␊ e = 0␍␊ n = size(x,"*")␍␊ for i = 1 : n␍␊ [s1,e1] = accsum_fasttwosum (e, x(i))␍␊ [s2,e2] = accsum_fasttwosum (s, s1)␍␊ [s,e] = accsum_fasttwosum (s2, e1 + e2)␍␊ end␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_dcs ( x )␊ // A Doubly Self Compensated Sum algorithm␊ // ␊ // Calling Sequence␊ // s = accsum_dcs ( x )␊ // [s,e] = accsum_dcs ( x )␊ // ␊ // Parameters␊ // x : a m-by-n, matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // A Doubly Self Compensated Sum algorithm.␊ // Uses accsum_fasttwosum.␊ // ␊ // Examples␊ // [s,e] = accsum_dcs ( [2 1] ) // 3␊ // [s,e] = accsum_dcs ( [1 2] ) // 3␊ // [s,e] = accsum_dcs ( [2 1] ) // 3␊ // [s,e] = accsum_dcs ( [1 2] ) // 3␊ // x = accsum_wilkinson(10); size(x,"*")␊ // s = sum(x)␊ // [s,e] = accsum_dcs ( x )␊ // [s,e] = accsum_dcs ( x )␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/ECMWF/img14.htm␊ // https://hpcrd.lbl.gov/SCG/ocean/NRS/SCSsum.F␊ ␊ s = 0␊ e = 0␊ n = size(x,"*")␊ for i = 1 : n␊ [s1,e1] = accsum_fasttwosum (e, x(i))␊ [s2,e2] = accsum_fasttwosum (s, s1)␊ [s,e] = accsum_fasttwosum (s2, e1 + e2)␊ end␊ endfunction␊ ␊
macros/accsum_order.sci
 1 1 2 2 3 3 4 4 5
 // Copyright (C) 2010 - Michael Baudin␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊
macros/accsum_fasttwosum.sci
 1 1 2 2 3 3 4 4 5 ... ... 10 11 11 12 12 13 14 13 15 14 16 15 17
 // Copyright (C) 2010 - Michael Baudin␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ // The fast2sum sum of a and b.␊ // ␊ // Calling Sequence␊ // s = accsum_fasttwosum ( a , b )␊ // [s,t] = accsum_fasttwosum ( a , b )␊ // ␊ // Parameters␊
macros/accsum_wilkinson.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function x = accsum_wilkinson ( r )␍␊ // A test vector by Wilkinson.␍␊ // ␍␊ // Calling Sequence␍␊ // x = accsum_wilkinson ( r )␍␊ // ␍␊ // Parameters␍␊ // r : a 1-by-1 matrix of doubles, a positive integer␍␊ // x : a 1-by-r, matrix of doubles␍␊ // ␍␊ // Description␍␊ // Returns a vector x of size 2^r where r is a flint.␍␊ // Exercise 4.2 in SNAA␍␊ // ␍␊ // Examples␍␊ // // 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]'␍␊ // ␍␊ // // Use with larger r␍␊ // x = accsum_wilkinson(10);␍␊ // s=sum(x)␍␊ // [s,e] = accsum_compsum ( x )␍␊ // [s,e] = accsum_dblcompsum ( x )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ n = 2^r␍␊ t = 53␍␊ u = 2^(-t) // would give the same as u = %eps␍␊ x(1) = 1␍␊ x(2) = 1 - u␍␊ for k = 2 : r␍␊ x(2^(k-1) + 1 : 2^k) = 1 - 2^(k-1) * u␍␊ end␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function x = accsum_wilkinson ( r )␊ // A test vector by Wilkinson.␊ // ␊ // Calling Sequence␊ // x = accsum_wilkinson ( r )␊ // ␊ // Parameters␊ // r : a 1-by-1 matrix of doubles, a positive integer␊ // x : a 1-by-r, matrix of doubles␊ // ␊ // Description␊ // Returns a vector x of size 2^r where r is a flint.␊ // Exercise 4.2 in SNAA␊ // ␊ // Examples␊ // // 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]'␊ // ␊ // // Use with larger r␊ // x = accsum_wilkinson(10);␊ // s=sum(x)␊ // [s,e] = accsum_compsum ( x )␊ // [s,e] = accsum_dblcompsum ( x )␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ n = 2^r␊ t = 53␊ u = 2^(-t) // would give the same as u = %eps␊ x(1) = 1␊ x(2) = 1 - u␊ for k = 2 : r␊ x(2^(k-1) + 1 : 2^k) = 1 - 2^(k-1) * u␊ end␊ endfunction␊ ␊
macros/accsum_orderdynamic.sci
 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 64 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 64 65
macros/accsum_compsum.sci
 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 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
 // Copyright (C) 2010 - 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␍␊ ␍␊ function [s,e] = accsum_compsum ( x )␍␊ // The compensated sum of a matrix.␍␊ // ␍␊ // Calling Sequence␍␊ // [s,e] = accsum_compsum ( x )␍␊ // ␍␊ // Parameters␍␊ // x : a n-by-m matrix of doubles␍␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␍␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␍␊ // ␍␊ // Description␍␊ // Returns the sum of x.␍␊ // Algorithm 4.4 in HFCC␍␊ // Due to Knuth␍␊ // No assumption on a , b␍␊ // Assumes that Scilab uses round-to-nearest.␍␊ // ␍␊ // Examples␍␊ // [s,e] = accsum_compsum ( [2 1] ) // 3␍␊ // [s,e] = accsum_compsum ( [1 2] ) // 3␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // [s,e] = accsum_compsum ( [1 %eps/2 ] )␍␊ // // is 1+(%eps/2) but is 1 without algo␍␊ // [s,e] = accsum_compsum ( [%eps/2 1] )␍␊ //␍␊ // Authors␍␊ // Michael Baudin, 2010␍␊ //␍␊ // Bibliography␍␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␍␊ // "Handbook of Floating Point Computations", Muller et al␍␊ ␍␊ s = 0␍␊ e = 0␍␊ n = size(x,"*")␍␊ for i = 1 : n␍␊ t = s␍␊ y = x(i) + e␍␊ s = t + y␍␊ e = (t - s) + y␍␊ end␍␊ endfunction␍␊ ␍␊ // Copyright (C) 2010 - 2011 - Michael Baudin␊ // Copyright (C) 2011 - DIGITEO - 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␊ ␊ function [s,e] = accsum_compsum ( x )␊ // The compensated sum of a matrix.␊ // ␊ // Calling Sequence␊ // s = accsum_compsum ( x )␊ // [s,e] = accsum_compsum ( x )␊ // ␊ // Parameters␊ // x : a n-by-m matrix of doubles␊ // s : a 1-by-1 matrix of doubles, the highest significant digits of the sum␊ // e : a 1-by-1, matrix of doubles, the lowest significant digits of the sum␊ // ␊ // Description␊ // Returns s and e such that s+e is the sum of x.␊ // Algorithm 4.4 in HFCC␊ // Due to Knuth␊ // No assumption on a , b␊ // Assumes that Scilab uses round-to-nearest.␊ // ␊ // Examples␊ // [s,e] = accsum_compsum ( [2 1] ) // 3␊ // [s,e] = accsum_compsum ( [1 2] ) // 3␊ // // is 1+(%eps/2) but is 1 without algo␊ // [s,e] = accsum_compsum ( [1 %eps/2 ] )␊ // // is 1+(%eps/2) but is 1 without algo␊ // [s,e] = accsum_compsum ( [%eps/2 1] )␊ //␊ // Authors␊ // Michael Baudin, 2010␊ //␊ // Bibliography␊ // "Stability and numerical accuracy of algorithms", Nicolas Higham␊ // "Handbook of Floating Point Computations", Muller et al␊ ␊ s = 0␊ e = 0␊ n = size(x,"*")␊ for i = 1 : n␊ t = s␊ y = x(i) + e␊ s = t + y␊ e = (t - s) + y␊ end␊ endfunction␊ ␊
changelog.txt
 7 7 8 8 9 9 10 10 11 11 12
 * Added gateway for compiled algorithms.␊ ␉* Created fdcs, fscs, fcomsum.␊ ␉* Downcased DCS and SCS.␊ * Fixed fast algorithms, added unit tests, help pages.␊ -- Michael Baudin March 2011␊ ␊