Tcl Library Source Code

Check-in [d535d2f0ea]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Correct several tests in the math module - they were failing in Tcl 8.5, seemingly not in Tcl 8.6. After these corrections there are still two tests left that need examination, both concerning test-anova-F in the statistics package.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d535d2f0ea8a2fc8d5993c0857b50e6ed9782300
User & Date: arjenmarkus 2017-01-08 10:06:51
Context
2017-01-09
20:18
Correct the tests for the ANOVA procedure and the comments regarding the purpose of ANOVA check-in: 55e0ff7a50 user: arjenmarkus tags: trunk
2017-01-08
10:06
Correct several tests in the math module - they were failing in Tcl 8.5, seemingly not in Tcl 8.6. After these corrections there are still two tests left that need examination, both concerning test-anova-F in the statistics package. check-in: d535d2f0ea user: arjenmarkus tags: trunk
2017-01-07
15:39
Module uri. In order to preserve backward compatibility, reverse many of the changes made in the previous commit. The module has a secondary role as a repository of useful regexp patterns, which are not entirely documented. Rearrange pattern definitions in an attempt to segregate the code for the two different roles. Undo deprecation of uri::register. Add comments to explain the purpose of each block of definitions. check-in: 6c65571dfa user: kjnash tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/math/geometry.test.

25
26
27
28
29
30
31











32
33
34
35
36
37
38
# -------------------------------------------------------------------------

proc withFourDecimals {args} {
    set res {}
    foreach arg $args {lappend res [expr (round(10000*$arg))/10000.0]}
    return $res
}












# -------------------------------------------------------------------------

###
# calculateDistanceToLine
###
test geometry-1.1 {geometry::calculateDistanceToLine, simple} {







>
>
>
>
>
>
>
>
>
>
>







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
# -------------------------------------------------------------------------

proc withFourDecimals {args} {
    set res {}
    foreach arg $args {lappend res [expr (round(10000*$arg))/10000.0]}
    return $res
}

if { [info commands lmap] eq {} } {
    proc lmap {var list body} {
        upvar 1 $var _$var
        set __$var {}
        foreach _$var $list {
            lappend __$var [uplevel 1 $body]
        }
        set __$var
    }
}

# -------------------------------------------------------------------------

###
# calculateDistanceToLine
###
test geometry-1.1 {geometry::calculateDistanceToLine, simple} {

Changes to modules/math/interpolate.test.

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165


166
167
168
169
170
171
172
173
     5.0 11.0 15.0
     9.9 11.0 19.9
    11.0 11.0 20.0
}

test "Interpolate-1.3" "Interpolate with integers" \
     -match numbers -body {
    set result {}

    set table [::math::interpolate::defineTable table1 \
                   {A B C D E} \
                   {0   0.00000   0.00000   0.00000   0.0000
                   1   0.52000   0.52000   0.52000   0.5200
                   3   0.69831   0.63142   0.67758   0.68457
                   5   0.86111   0.71690   0.81118   0.80365
                   7   1.01367   0.78725   0.92891   0.89851}]

    foreach A {2 4 6} A2 {2.0 4.0 6.0} {
        set intResults   [::math::interpolate::interp-1d-table $table $A]
        set floatResults [::math::interpolate::interp-1d-table $table $A2]
        set equal 1
        foreach i $intResults f $floatResults {
            if { $i != $f } {
                set equal 0
                break
            }
       }
       lappend equalResults $equal
   }


} {1 1 1}

# linear interpolation: y = x + 1 and y = 2*x, x<5, or 20-2*x, x>5

test "Interpolate-2.1" "Linear interpolation - 1" \
     -match numbers -body {
   set result {}








|

|



















>
>
|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
     5.0 11.0 15.0
     9.9 11.0 19.9
    11.0 11.0 20.0
}

test "Interpolate-1.3" "Interpolate with integers" \
     -match numbers -body {
    set equalResults {}

    set table [::math::interpolate::defineTable table3 \
                   {A B C D E} \
                   {0   0.00000   0.00000   0.00000   0.0000
                   1   0.52000   0.52000   0.52000   0.5200
                   3   0.69831   0.63142   0.67758   0.68457
                   5   0.86111   0.71690   0.81118   0.80365
                   7   1.01367   0.78725   0.92891   0.89851}]

    foreach A {2 4 6} A2 {2.0 4.0 6.0} {
        set intResults   [::math::interpolate::interp-1d-table $table $A]
        set floatResults [::math::interpolate::interp-1d-table $table $A2]
        set equal 1
        foreach i $intResults f $floatResults {
            if { $i != $f } {
                set equal 0
                break
            }
       }
       lappend equalResults $equal
   }

   return $equalResults
} -result {1 1 1}

# linear interpolation: y = x + 1 and y = 2*x, x<5, or 20-2*x, x>5

test "Interpolate-2.1" "Linear interpolation - 1" \
     -match numbers -body {
   set result {}

Changes to modules/math/linalg.test.

512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
                {1000    1    1   10}
                {   1 1000   10  100}
                {  10   10  100    1}}
    set b      {610 1003.3 133 31.3}

    set xvec2 [solveGauss $matrix $b]

    set closeValues [areClose $xvec1 $xvec2 1.0-e8]
} -result {1 1 1 1}

test solvepgauss-1.6 "solveGauss - 2x2 difficult matrix with necessary permutations" -match numbers -body {
    set M {{1.e-8 1} {1 1}}
    set b [list [expr {1.+1.e-8}] 2.]
    set computed [solveGauss $M $b]
    set expected {1. 1.}
    set diff [sub $computed $expected]







|
|







512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
                {1000    1    1   10}
                {   1 1000   10  100}
                {  10   10  100    1}}
    set b      {610 1003.3 133 31.3}

    set xvec2 [solveGauss $matrix $b]

    set closeValues [areClose $xvec1 $xvec2 1.0e-8]
} -result 1

test solvepgauss-1.6 "solveGauss - 2x2 difficult matrix with necessary permutations" -match numbers -body {
    set M {{1.e-8 1} {1 1}}
    set b [list [expr {1.+1.e-8}] 2.]
    set computed [solveGauss $M $b]
    set expected {1. 1.}
    set diff [sub $computed $expected]