Skip to content

Commit 16e6d6d

Browse files
author
Sébastien Loisel
committed
Preparing for 1.0.0: code review
1 parent b39c4da commit 16e6d6d

File tree

4 files changed

+87
-96
lines changed

4 files changed

+87
-96
lines changed

documentation.html

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,15 @@ <h1>Singular value decomposition (Shanti Rao)</h1>
596596
<h1>Sparse linear algebra</h1>
597597
Sparse linear algebra is available in the sparse module:
598598
<pre>
599-
> sparse.identity(3)
599+
> numeric.sidentity(3)
600600
[[1],
601601
[ ,1],
602602
[ , ,1]]
603-
> sparse.transpose([[1],[2,3],[4,5,6]])
603+
> numeric.stranspose([[1],[2,3],[4,5,6]])
604604
[[1,2,4],
605605
[ ,3,5],
606606
[ , ,6]]
607-
> A = [[2,-1],[-1,2,-1],[,-1,2]]; lup = sparse.LUP(A)
607+
> A = [[2,-1],[-1,2,-1],[,-1,2]]; lup = numeric.sLUP(A)
608608
{L: [[ 1],
609609
[-0.5, 1],
610610
[ ,-0.6667, 1]],
@@ -613,36 +613,36 @@ <h1>Sparse linear algebra</h1>
613613
[ , , 1.333]],
614614
P: [0,1,2],
615615
Pinv: [0,1,2]}
616-
> sparse.dot(lup.L,lup.U)
616+
> numeric.sdot(lup.L,lup.U)
617617
[[ 2, -1],
618618
[ -1, 2, -1],
619619
[ , -1, 2]]
620-
> x = [3,1,7]; b = sparse.dot(A,x);
620+
> x = [3,1,7]; b = numeric.sdot(A,x);
621621
[5,-8,13]
622-
> sparse.LUPsolve(lup,b)
622+
> numeric.sLUPsolve(lup,b)
623623
[3,1,7]
624624
</pre>
625625

626626
<!--
627627
Some more tests.
628628
<pre>
629-
> sparse.dot([1,2,3],[,4,5])
629+
> numeric.sdot([1,2,3],[,4,5])
630630
23
631-
> sparse.dot([1, ,3],[[4,5,],[,6,7],[1,,8]])
631+
> numeric.sdot([1, ,3],[[4,5,],[,6,7],[1,,8]])
632632
[7,5,24]
633-
> sparse.dot([[3,1],[4,5,9],[,3,2]],[7,3])
633+
> numeric.sdot([[3,1],[4,5,9],[,3,2]],[7,3])
634634
[24,43,9]
635635
</pre>
636636
-->
637637

638-
The <tt>sparse.scatter()</tt> and <tt>sparse.gather()</tt> functions can be used to convert between
638+
The <tt>numeric.sscatter()</tt> and <tt>numeric.sgather()</tt> functions can be used to convert between
639639
sparse matrices and the coordinate encoding:
640640
<pre>
641-
> A = sparse.scatter([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[1,2,3,4,5,6,7]])
641+
> A = numeric.sscatter([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[1,2,3,4,5,6,7]])
642642
[[1,2],
643643
[3,4,5],
644644
[ ,6,7]]
645-
> sparse.gather(A)
645+
> numeric.sgather(A)
646646
[[0,0,1,1,1,2,2],
647647
[0,1,0,1,2,1,2],
648648
[1,2,3,4,5,6,7]]
@@ -656,35 +656,35 @@ <h1>Coordinate matrices</h1>
656656

657657
LU decomposition:
658658
<pre>
659-
> lu = coord.LU([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[2,-1,-1,2,-1,-1,2]])
659+
> lu = numeric.cLU([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[2,-1,-1,2,-1,-1,2]])
660660
{U:[[ 0, 0, 1, 1, 2 ],
661661
[ 0, 1, 1, 2, 2 ],
662662
[ 2, -1, 1.5, -1, 1.333]],
663663
L:[[ 0, 1, 1, 2, 2 ],
664664
[ 0, 0, 1, 1, 2 ],
665665
[ 1, -0.5, 1,-0.6667, 1 ]]}
666-
> coord.LUsolve(lu,[5,-8,13])
666+
> numeric.cLUsolve(lu,[5,-8,13])
667667
[3,1,7]
668668
</pre>
669-
Note that <tt>coord.LU()</tt> does not have any pivoting.
669+
Note that <tt>numeric.cLU()</tt> does not have any pivoting.
670670

671671
<h1>Solving PDEs</h1>
672672

673-
The functions <tt>coord.grid()</tt> and <tt>coord.delsq()</tt> can be used to obtain a
673+
The functions <tt>numeric.cgrid()</tt> and <tt>numeric.cdelsq()</tt> can be used to obtain a
674674
numerical Laplacian for a domain.
675675

676676
<pre>
677-
> g = coord.grid(5)
677+
> g = numeric.cgrid(5)
678678
[[-1,-1,-1,-1,-1],
679679
[-1, 0, 1, 2,-1],
680680
[-1, 3, 4, 5,-1],
681681
[-1, 6, 7, 8,-1],
682682
[-1,-1,-1,-1,-1]]
683-
> coordL = coord.delsq(g)
683+
> coordL = numeric.cdelsq(g)
684684
[[ 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8],
685685
[ 1, 3, 0, 0, 2, 4, 1, 1, 5, 2, 0, 4, 6, 3, 1, 3, 5, 7, 4, 2, 4, 8, 5, 3, 7, 6, 4, 6, 8, 7, 5, 7, 8],
686686
[-1,-1, 4,-1,-1,-1, 4,-1,-1, 4,-1,-1,-1, 4,-1,-1,-1,-1, 4,-1,-1,-1, 4,-1,-1, 4,-1,-1,-1, 4,-1,-1, 4]]
687-
> L = sparse.scatter(coordL); // Just to see what it looks like
687+
> L = numeric.sscatter(coordL); // Just to see what it looks like
688688
[[ 4, -1, , -1],
689689
[ -1, 4, -1, , -1],
690690
[ , -1, 4, , , -1],
@@ -694,9 +694,9 @@ <h1>Solving PDEs</h1>
694694
[ , , , -1, , , 4, -1],
695695
[ , , , , -1, , -1, 4, -1],
696696
[ , , , , , -1, , -1, 4]]
697-
> lu = coord.LU(coordL); x = coord.LUsolve(lu,[1,1,1,1,1,1,1,1,1]);
697+
> lu = numeric.cLU(coordL); x = numeric.cLUsolve(lu,[1,1,1,1,1,1,1,1,1]);
698698
[0.6875,0.875,0.6875,0.875,1.125,0.875,0.6875,0.875,0.6875]
699-
> coord.dotMV(coordL,x)
699+
> numeric.cdotMV(coordL,x)
700700
[1,1,1,1,1,1,1,1,1]
701701
> G = numeric.rep([5,5],0); for(i=0;i<5;i++) for(j=0;j<5;j++) if(g[i][j]>=0) G[i][j] = x[g[i][j]]; G
702702
[[ 0 , 0 , 0 , 0 , 0 ],
@@ -710,14 +710,14 @@ <h1>Solving PDEs</h1>
710710

711711
You can also work on an L-shaped or arbitrary-shape domain:
712712
<pre>
713-
> coord.grid(6,'L')
713+
> numeric.cgrid(6,'L')
714714
[[-1,-1,-1,-1,-1,-1],
715715
[-1, 0, 1,-1,-1,-1],
716716
[-1, 2, 3,-1,-1,-1],
717717
[-1, 4, 5, 6, 7,-1],
718718
[-1, 8, 9,10,11,-1],
719719
[-1,-1,-1,-1,-1,-1]]
720-
> coord.grid(5,function(i,j) { return i!==2 || j!==2; })
720+
> numeric.cgrid(5,function(i,j) { return i!==2 || j!==2; })
721721
[[-1,-1,-1,-1,-1],
722722
[-1, 0, 1, 2,-1],
723723
[-1, 3,-1, 4,-1],

src/documentation.html

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,15 @@ <h1>Singular value decomposition (Shanti Rao)</h1>
596596
<h1>Sparse linear algebra</h1>
597597
Sparse linear algebra is available in the sparse module:
598598
<pre>
599-
> sparse.identity(3)
599+
> numeric.sidentity(3)
600600
[[1],
601601
[ ,1],
602602
[ , ,1]]
603-
> sparse.transpose([[1],[2,3],[4,5,6]])
603+
> numeric.stranspose([[1],[2,3],[4,5,6]])
604604
[[1,2,4],
605605
[ ,3,5],
606606
[ , ,6]]
607-
> A = [[2,-1],[-1,2,-1],[,-1,2]]; lup = sparse.LUP(A)
607+
> A = [[2,-1],[-1,2,-1],[,-1,2]]; lup = numeric.sLUP(A)
608608
{L: [[ 1],
609609
[-0.5, 1],
610610
[ ,-0.6667, 1]],
@@ -613,36 +613,36 @@ <h1>Sparse linear algebra</h1>
613613
[ , , 1.333]],
614614
P: [0,1,2],
615615
Pinv: [0,1,2]}
616-
> sparse.dot(lup.L,lup.U)
616+
> numeric.sdot(lup.L,lup.U)
617617
[[ 2, -1],
618618
[ -1, 2, -1],
619619
[ , -1, 2]]
620-
> x = [3,1,7]; b = sparse.dot(A,x);
620+
> x = [3,1,7]; b = numeric.sdot(A,x);
621621
[5,-8,13]
622-
> sparse.LUPsolve(lup,b)
622+
> numeric.sLUPsolve(lup,b)
623623
[3,1,7]
624624
</pre>
625625

626626
<!--
627627
Some more tests.
628628
<pre>
629-
> sparse.dot([1,2,3],[,4,5])
629+
> numeric.sdot([1,2,3],[,4,5])
630630
23
631-
> sparse.dot([1, ,3],[[4,5,],[,6,7],[1,,8]])
631+
> numeric.sdot([1, ,3],[[4,5,],[,6,7],[1,,8]])
632632
[7,5,24]
633-
> sparse.dot([[3,1],[4,5,9],[,3,2]],[7,3])
633+
> numeric.sdot([[3,1],[4,5,9],[,3,2]],[7,3])
634634
[24,43,9]
635635
</pre>
636636
-->
637637

638-
The <tt>sparse.scatter()</tt> and <tt>sparse.gather()</tt> functions can be used to convert between
638+
The <tt>numeric.sscatter()</tt> and <tt>numeric.sgather()</tt> functions can be used to convert between
639639
sparse matrices and the coordinate encoding:
640640
<pre>
641-
> A = sparse.scatter([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[1,2,3,4,5,6,7]])
641+
> A = numeric.sscatter([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[1,2,3,4,5,6,7]])
642642
[[1,2],
643643
[3,4,5],
644644
[ ,6,7]]
645-
> sparse.gather(A)
645+
> numeric.sgather(A)
646646
[[0,0,1,1,1,2,2],
647647
[0,1,0,1,2,1,2],
648648
[1,2,3,4,5,6,7]]
@@ -656,35 +656,35 @@ <h1>Coordinate matrices</h1>
656656

657657
LU decomposition:
658658
<pre>
659-
> lu = coord.LU([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[2,-1,-1,2,-1,-1,2]])
659+
> lu = numeric.cLU([[0,0,1,1,1,2,2],[0,1,0,1,2,1,2],[2,-1,-1,2,-1,-1,2]])
660660
{U:[[ 0, 0, 1, 1, 2 ],
661661
[ 0, 1, 1, 2, 2 ],
662662
[ 2, -1, 1.5, -1, 1.333]],
663663
L:[[ 0, 1, 1, 2, 2 ],
664664
[ 0, 0, 1, 1, 2 ],
665665
[ 1, -0.5, 1,-0.6667, 1 ]]}
666-
> coord.LUsolve(lu,[5,-8,13])
666+
> numeric.cLUsolve(lu,[5,-8,13])
667667
[3,1,7]
668668
</pre>
669-
Note that <tt>coord.LU()</tt> does not have any pivoting.
669+
Note that <tt>numeric.cLU()</tt> does not have any pivoting.
670670

671671
<h1>Solving PDEs</h1>
672672

673-
The functions <tt>coord.grid()</tt> and <tt>coord.delsq()</tt> can be used to obtain a
673+
The functions <tt>numeric.cgrid()</tt> and <tt>numeric.cdelsq()</tt> can be used to obtain a
674674
numerical Laplacian for a domain.
675675

676676
<pre>
677-
> g = coord.grid(5)
677+
> g = numeric.cgrid(5)
678678
[[-1,-1,-1,-1,-1],
679679
[-1, 0, 1, 2,-1],
680680
[-1, 3, 4, 5,-1],
681681
[-1, 6, 7, 8,-1],
682682
[-1,-1,-1,-1,-1]]
683-
> coordL = coord.delsq(g)
683+
> coordL = numeric.cdelsq(g)
684684
[[ 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8],
685685
[ 1, 3, 0, 0, 2, 4, 1, 1, 5, 2, 0, 4, 6, 3, 1, 3, 5, 7, 4, 2, 4, 8, 5, 3, 7, 6, 4, 6, 8, 7, 5, 7, 8],
686686
[-1,-1, 4,-1,-1,-1, 4,-1,-1, 4,-1,-1,-1, 4,-1,-1,-1,-1, 4,-1,-1,-1, 4,-1,-1, 4,-1,-1,-1, 4,-1,-1, 4]]
687-
> L = sparse.scatter(coordL); // Just to see what it looks like
687+
> L = numeric.sscatter(coordL); // Just to see what it looks like
688688
[[ 4, -1, , -1],
689689
[ -1, 4, -1, , -1],
690690
[ , -1, 4, , , -1],
@@ -694,9 +694,9 @@ <h1>Solving PDEs</h1>
694694
[ , , , -1, , , 4, -1],
695695
[ , , , , -1, , -1, 4, -1],
696696
[ , , , , , -1, , -1, 4]]
697-
> lu = coord.LU(coordL); x = coord.LUsolve(lu,[1,1,1,1,1,1,1,1,1]);
697+
> lu = numeric.cLU(coordL); x = numeric.cLUsolve(lu,[1,1,1,1,1,1,1,1,1]);
698698
[0.6875,0.875,0.6875,0.875,1.125,0.875,0.6875,0.875,0.6875]
699-
> coord.dotMV(coordL,x)
699+
> numeric.cdotMV(coordL,x)
700700
[1,1,1,1,1,1,1,1,1]
701701
> G = numeric.rep([5,5],0); for(i=0;i<5;i++) for(j=0;j<5;j++) if(g[i][j]>=0) G[i][j] = x[g[i][j]]; G
702702
[[ 0 , 0 , 0 , 0 , 0 ],
@@ -710,14 +710,14 @@ <h1>Solving PDEs</h1>
710710

711711
You can also work on an L-shaped or arbitrary-shape domain:
712712
<pre>
713-
> coord.grid(6,'L')
713+
> numeric.cgrid(6,'L')
714714
[[-1,-1,-1,-1,-1,-1],
715715
[-1, 0, 1,-1,-1,-1],
716716
[-1, 2, 3,-1,-1,-1],
717717
[-1, 4, 5, 6, 7,-1],
718718
[-1, 8, 9,10,11,-1],
719719
[-1,-1,-1,-1,-1,-1]]
720-
> coord.grid(5,function(i,j) { return i!==2 || j!==2; })
720+
> numeric.cgrid(5,function(i,j) { return i!==2 || j!==2; })
721721
[[-1,-1,-1,-1,-1],
722722
[-1, 0, 1, 2,-1],
723723
[-1, 3,-1, 4,-1],

0 commit comments

Comments
 (0)