From ebf6cbaa0d7dd114aa2b29113d25addfdbae9f79 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 30 Jan 2009 11:42:43 -0600 Subject: [PATCH] remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices --- basis/math/blas/matrices/matrices-docs.factor | 52 +++++++++++++++-- basis/math/blas/matrices/matrices-tests.factor | 2 +- basis/math/blas/matrices/matrices.factor | 12 +++- basis/math/blas/syntax/authors.txt | 1 - basis/math/blas/syntax/summary.txt | 1 - basis/math/blas/syntax/syntax-docs.factor | 78 ------------------------- basis/math/blas/syntax/syntax.factor | 44 -------------- basis/math/blas/syntax/tags.txt | 1 - basis/math/blas/vectors/vectors-docs.factor | 29 ++++++++- basis/math/blas/vectors/vectors-tests.factor | 2 +- basis/math/blas/vectors/vectors.factor | 11 +++- extra/sequences/squish/.squish.factor.swo | Bin 12288 -> 12288 bytes extra/sequences/squish/squish.factor | 1 - 13 files changed, 99 insertions(+), 135 deletions(-) delete mode 100644 basis/math/blas/syntax/authors.txt delete mode 100644 basis/math/blas/syntax/summary.txt delete mode 100644 basis/math/blas/syntax/syntax-docs.factor delete mode 100644 basis/math/blas/syntax/syntax.factor delete mode 100644 basis/math/blas/syntax/tags.txt diff --git a/basis/math/blas/matrices/matrices-docs.factor b/basis/math/blas/matrices/matrices-docs.factor index 01e0997405..f20a565e1f 100644 --- a/basis/math/blas/matrices/matrices-docs.factor +++ b/basis/math/blas/matrices/matrices-docs.factor @@ -1,4 +1,4 @@ -USING: alien byte-arrays help.markup help.syntax math math.blas.vectors sequences strings ; +USING: alien byte-arrays help.markup help.syntax math math.blas.vectors sequences strings multiline ; IN: math.blas.matrices ARTICLE: "math.blas-summary" "Basic Linear Algebra Subroutines (BLAS) interface" @@ -21,8 +21,6 @@ ARTICLE: "math.blas-types" "BLAS interface types" { $subsection double-blas-matrix } { $subsection float-complex-blas-matrix } { $subsection double-complex-blas-matrix } -"Syntax words are provided for constructing literal vectors and matrices in the " { $vocab-link "math.blas.syntax" } " vocabulary:" -{ $subsection "math.blas.syntax" } "There are BOA constructors for all vector and matrix types, which provide the most flexibility in specifying memory layout:" { $subsection } { $subsection } @@ -74,7 +72,13 @@ ARTICLE: "math.blas.matrices" "BLAS interface matrix operations" { $subsection n*M! } { $subsection n*M } { $subsection M*n } -{ $subsection M/n } ; +{ $subsection M/n } +"Literal syntax:" +{ $subsection POSTPONE: smatrix{ } +{ $subsection POSTPONE: dmatrix{ } +{ $subsection POSTPONE: cmatrix{ } +{ $subsection POSTPONE: zmatrix{ } ; + ABOUT: "math.blas.matrices" @@ -243,3 +247,43 @@ HELP: { $values { "length" "The length of the new vector" } { "exemplar" blas-vector-base blas-matrix-base } { "vector" blas-vector-base } } { $description "Return a vector of zeros with the given " { $snippet "length" } " and the same element type as " { $snippet "v" } "." } ; +HELP: smatrix{ +{ $syntax <" smatrix{ + { 1.0 0.0 0.0 1.0 } + { 0.0 1.0 0.0 2.0 } + { 0.0 0.0 1.0 3.0 } + { 0.0 0.0 0.0 1.0 } +} "> } +{ $description "Construct a literal " { $link float-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; + +HELP: dmatrix{ +{ $syntax <" dmatrix{ + { 1.0 0.0 0.0 1.0 } + { 0.0 1.0 0.0 2.0 } + { 0.0 0.0 1.0 3.0 } + { 0.0 0.0 0.0 1.0 } +} "> } +{ $description "Construct a literal " { $link double-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; + +HELP: cmatrix{ +{ $syntax <" cmatrix{ + { 1.0 0.0 0.0 1.0 } + { 0.0 C{ 0.0 1.0 } 0.0 2.0 } + { 0.0 0.0 -1.0 3.0 } + { 0.0 0.0 0.0 C{ 0.0 -1.0 } } +} "> } +{ $description "Construct a literal " { $link float-complex-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; + +HELP: zmatrix{ +{ $syntax <" zmatrix{ + { 1.0 0.0 0.0 1.0 } + { 0.0 C{ 0.0 1.0 } 0.0 2.0 } + { 0.0 0.0 -1.0 3.0 } + { 0.0 0.0 0.0 C{ 0.0 -1.0 } } +} "> } +{ $description "Construct a literal " { $link double-complex-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; + +{ + POSTPONE: smatrix{ POSTPONE: dmatrix{ + POSTPONE: cmatrix{ POSTPONE: zmatrix{ +} related-words diff --git a/basis/math/blas/matrices/matrices-tests.factor b/basis/math/blas/matrices/matrices-tests.factor index dabf3c3ee9..cf0c25745e 100644 --- a/basis/math/blas/matrices/matrices-tests.factor +++ b/basis/math/blas/matrices/matrices-tests.factor @@ -1,4 +1,4 @@ -USING: kernel math.blas.matrices math.blas.vectors math.blas.syntax +USING: kernel math.blas.matrices math.blas.vectors sequences tools.test ; IN: math.blas.matrices.tests diff --git a/basis/math/blas/matrices/matrices.factor b/basis/math/blas/matrices/matrices.factor index f6b98e3ae2..7b03ddf42a 100755 --- a/basis/math/blas/matrices/matrices.factor +++ b/basis/math/blas/matrices/matrices.factor @@ -4,7 +4,8 @@ math math.blas.cblas math.blas.vectors math.blas.vectors.private math.complex math.functions math.order functors words sequences sequences.merged sequences.private shuffle specialized-arrays.direct.float specialized-arrays.direct.double -specialized-arrays.float specialized-arrays.double ; +specialized-arrays.float specialized-arrays.double +parser prettyprint.backend prettyprint.custom ; IN: math.blas.matrices TUPLE: blas-matrix-base underlying ld rows cols transpose ; @@ -258,6 +259,7 @@ XGERC IS cblas_${T}ger${C} MATRIX DEFINES ${TYPE}-blas-matrix DEFINES <${TYPE}-blas-matrix> >MATRIX DEFINES >${TYPE}-blas-matrix +XMATRIX{ DEFINES ${T}matrix{ WHERE @@ -291,6 +293,11 @@ M: MATRIX n*V(*)Vconj+M! [ TYPE>ARG ] (prepare-ger) [ XGERC ] dip ; +: XMATRIX{ \ } [ >MATRIX ] parse-literal ; parsing + +M: MATRIX pprint-delims + drop \ XMATRIX{ \ } ; + ;FUNCTOR @@ -305,3 +312,6 @@ M: MATRIX n*V(*)Vconj+M! "double-complex" "z" define-complex-blas-matrix >> + +M: blas-matrix-base >pprint-sequence Mrows ; +M: blas-matrix-base pprint* pprint-object ; diff --git a/basis/math/blas/syntax/authors.txt b/basis/math/blas/syntax/authors.txt deleted file mode 100644 index f13c9c1e77..0000000000 --- a/basis/math/blas/syntax/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Joe Groff diff --git a/basis/math/blas/syntax/summary.txt b/basis/math/blas/syntax/summary.txt deleted file mode 100644 index a71bebb50f..0000000000 --- a/basis/math/blas/syntax/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Literal syntax for BLAS vectors and matrices diff --git a/basis/math/blas/syntax/syntax-docs.factor b/basis/math/blas/syntax/syntax-docs.factor deleted file mode 100644 index 6b58df738a..0000000000 --- a/basis/math/blas/syntax/syntax-docs.factor +++ /dev/null @@ -1,78 +0,0 @@ -USING: help.markup help.syntax math.blas.matrices math.blas.vectors multiline ; -IN: math.blas.syntax - -ARTICLE: "math.blas.syntax" "BLAS interface literal syntax" -"Vectors:" -{ $subsection POSTPONE: svector{ } -{ $subsection POSTPONE: dvector{ } -{ $subsection POSTPONE: cvector{ } -{ $subsection POSTPONE: zvector{ } -"Matrices:" -{ $subsection POSTPONE: smatrix{ } -{ $subsection POSTPONE: dmatrix{ } -{ $subsection POSTPONE: cmatrix{ } -{ $subsection POSTPONE: zmatrix{ } ; - -ABOUT: "math.blas.syntax" - -HELP: svector{ -{ $syntax "svector{ 1.0 -2.0 3.0 }" } -{ $description "Construct a literal " { $link float-blas-vector } "." } ; - -HELP: dvector{ -{ $syntax "dvector{ 1.0 -2.0 3.0 }" } -{ $description "Construct a literal " { $link double-blas-vector } "." } ; - -HELP: cvector{ -{ $syntax "cvector{ 1.0 -2.0 C{ 3.0 -1.0 } }" } -{ $description "Construct a literal " { $link float-complex-blas-vector } "." } ; - -HELP: zvector{ -{ $syntax "dvector{ 1.0 -2.0 C{ 3.0 -1.0 } }" } -{ $description "Construct a literal " { $link double-complex-blas-vector } "." } ; - -{ - POSTPONE: svector{ POSTPONE: dvector{ - POSTPONE: cvector{ POSTPONE: zvector{ -} related-words - -HELP: smatrix{ -{ $syntax <" smatrix{ - { 1.0 0.0 0.0 1.0 } - { 0.0 1.0 0.0 2.0 } - { 0.0 0.0 1.0 3.0 } - { 0.0 0.0 0.0 1.0 } -} "> } -{ $description "Construct a literal " { $link float-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; - -HELP: dmatrix{ -{ $syntax <" dmatrix{ - { 1.0 0.0 0.0 1.0 } - { 0.0 1.0 0.0 2.0 } - { 0.0 0.0 1.0 3.0 } - { 0.0 0.0 0.0 1.0 } -} "> } -{ $description "Construct a literal " { $link double-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; - -HELP: cmatrix{ -{ $syntax <" cmatrix{ - { 1.0 0.0 0.0 1.0 } - { 0.0 C{ 0.0 1.0 } 0.0 2.0 } - { 0.0 0.0 -1.0 3.0 } - { 0.0 0.0 0.0 C{ 0.0 -1.0 } } -} "> } -{ $description "Construct a literal " { $link float-complex-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; - -HELP: zmatrix{ -{ $syntax <" zmatrix{ - { 1.0 0.0 0.0 1.0 } - { 0.0 C{ 0.0 1.0 } 0.0 2.0 } - { 0.0 0.0 -1.0 3.0 } - { 0.0 0.0 0.0 C{ 0.0 -1.0 } } -} "> } -{ $description "Construct a literal " { $link double-complex-blas-matrix } ". Note that although BLAS matrices are stored in column-major order, the literal is specified in row-major order." } ; - -{ - POSTPONE: smatrix{ POSTPONE: dmatrix{ - POSTPONE: cmatrix{ POSTPONE: zmatrix{ -} related-words diff --git a/basis/math/blas/syntax/syntax.factor b/basis/math/blas/syntax/syntax.factor deleted file mode 100644 index 2d171a801b..0000000000 --- a/basis/math/blas/syntax/syntax.factor +++ /dev/null @@ -1,44 +0,0 @@ -USING: kernel math.blas.vectors math.blas.matrices parser -arrays prettyprint.backend prettyprint.custom sequences ; -IN: math.blas.syntax - -: svector{ - \ } [ >float-blas-vector ] parse-literal ; parsing -: dvector{ - \ } [ >double-blas-vector ] parse-literal ; parsing -: cvector{ - \ } [ >float-complex-blas-vector ] parse-literal ; parsing -: zvector{ - \ } [ >double-complex-blas-vector ] parse-literal ; parsing - -: smatrix{ - \ } [ >float-blas-matrix ] parse-literal ; parsing -: dmatrix{ - \ } [ >double-blas-matrix ] parse-literal ; parsing -: cmatrix{ - \ } [ >float-complex-blas-matrix ] parse-literal ; parsing -: zmatrix{ - \ } [ >double-complex-blas-matrix ] parse-literal ; parsing - -M: float-blas-vector pprint-delims - drop \ svector{ \ } ; -M: double-blas-vector pprint-delims - drop \ dvector{ \ } ; -M: float-complex-blas-vector pprint-delims - drop \ cvector{ \ } ; -M: double-complex-blas-vector pprint-delims - drop \ zvector{ \ } ; - -M: float-blas-matrix pprint-delims - drop \ smatrix{ \ } ; -M: double-blas-matrix pprint-delims - drop \ dmatrix{ \ } ; -M: float-complex-blas-matrix pprint-delims - drop \ cmatrix{ \ } ; -M: double-complex-blas-matrix pprint-delims - drop \ zmatrix{ \ } ; - -M: blas-vector-base >pprint-sequence ; -M: blas-vector-base pprint* pprint-object ; -M: blas-matrix-base >pprint-sequence Mrows ; -M: blas-matrix-base pprint* pprint-object ; diff --git a/basis/math/blas/syntax/tags.txt b/basis/math/blas/syntax/tags.txt deleted file mode 100644 index ede10ab61b..0000000000 --- a/basis/math/blas/syntax/tags.txt +++ /dev/null @@ -1 +0,0 @@ -math diff --git a/basis/math/blas/vectors/vectors-docs.factor b/basis/math/blas/vectors/vectors-docs.factor index cb26d67334..b37a4b966e 100644 --- a/basis/math/blas/vectors/vectors-docs.factor +++ b/basis/math/blas/vectors/vectors-docs.factor @@ -23,7 +23,12 @@ ARTICLE: "math.blas.vectors" "BLAS interface vector operations" { $subsection V- } "Vector inner products:" { $subsection V. } -{ $subsection V.conj } ; +{ $subsection V.conj } +"Literal syntax:" +{ $subsection POSTPONE: svector{ } +{ $subsection POSTPONE: dvector{ } +{ $subsection POSTPONE: cvector{ } +{ $subsection POSTPONE: zvector{ } ; ABOUT: "math.blas.vectors" @@ -129,3 +134,25 @@ HELP: V/n HELP: Vsub { $values { "v" blas-vector-base } { "start" integer } { "length" integer } { "sub" blas-vector-base } } { $description "Slice a subvector out of " { $snippet "v" } " starting at " { $snippet "start" } " with the given " { $snippet "length" } ". The subvector will share storage with the parent vector." } ; + +HELP: svector{ +{ $syntax "svector{ 1.0 -2.0 3.0 }" } +{ $description "Construct a literal " { $link float-blas-vector } "." } ; + +HELP: dvector{ +{ $syntax "dvector{ 1.0 -2.0 3.0 }" } +{ $description "Construct a literal " { $link double-blas-vector } "." } ; + +HELP: cvector{ +{ $syntax "cvector{ 1.0 -2.0 C{ 3.0 -1.0 } }" } +{ $description "Construct a literal " { $link float-complex-blas-vector } "." } ; + +HELP: zvector{ +{ $syntax "dvector{ 1.0 -2.0 C{ 3.0 -1.0 } }" } +{ $description "Construct a literal " { $link double-complex-blas-vector } "." } ; + +{ + POSTPONE: svector{ POSTPONE: dvector{ + POSTPONE: cvector{ POSTPONE: zvector{ +} related-words + diff --git a/basis/math/blas/vectors/vectors-tests.factor b/basis/math/blas/vectors/vectors-tests.factor index 5f9e8fdc42..da271a4fc7 100644 --- a/basis/math/blas/vectors/vectors-tests.factor +++ b/basis/math/blas/vectors/vectors-tests.factor @@ -1,4 +1,4 @@ -USING: kernel math.blas.vectors math.blas.syntax sequences tools.test ; +USING: kernel math.blas.vectors sequences tools.test ; IN: math.blas.vectors.tests ! clone diff --git a/basis/math/blas/vectors/vectors.factor b/basis/math/blas/vectors/vectors.factor index c86fa30115..3b7f89f730 100755 --- a/basis/math/blas/vectors/vectors.factor +++ b/basis/math/blas/vectors/vectors.factor @@ -2,7 +2,7 @@ USING: accessors alien alien.c-types arrays byte-arrays combinators combinators.short-circuit fry kernel math math.blas.cblas math.complex math.functions math.order sequences.complex sequences.complex-components sequences sequences.private -functors words locals +functors words locals parser prettyprint.backend prettyprint.custom specialized-arrays.float specialized-arrays.double specialized-arrays.direct.float specialized-arrays.direct.double ; IN: math.blas.vectors @@ -138,6 +138,8 @@ VECTOR DEFINES ${TYPE}-blas-vector DEFINES <${TYPE}-blas-vector> >VECTOR DEFINES >${TYPE}-blas-vector +XVECTOR{ DEFINES ${T}vector{ + WHERE TUPLE: VECTOR < blas-vector-base ; @@ -165,6 +167,11 @@ M: VECTOR (blas-direct-array) [ [ length>> ] [ inc>> ] bi * ] bi ; +: XVECTOR{ \ } [ >VECTOR ] parse-literal ; parsing + +M: VECTOR pprint-delims + drop \ XVECTOR{ \ } ; + ;FUNCTOR @@ -270,3 +277,5 @@ M: VECTOR n*V! >> +M: blas-vector-base >pprint-sequence ; +M: blas-vector-base pprint* pprint-object ; diff --git a/extra/sequences/squish/.squish.factor.swo b/extra/sequences/squish/.squish.factor.swo index 71a1d2add76591b46e66acf75ed3a2f34376dc7d..ca9453dd0caf1e72273bb82674e6c764e9f681da 100644 GIT binary patch delta 69 zcwTErXh@JxG6?hZRWR2xVgLdG28JB7W>23fDGYmo+^qc6i3e3Tx}4x=?`A=T_xu2XqY)nf diff --git a/extra/sequences/squish/squish.factor b/extra/sequences/squish/squish.factor index c42747af47..214c6895e2 100644 --- a/extra/sequences/squish/squish.factor +++ b/extra/sequences/squish/squish.factor @@ -10,4 +10,3 @@ IN: sequences.squish : squish-strings ( seq -- seq' ) [ { [ sequence? ] [ integer? not ] } 1&& ] "" squish ; - -- 2.11.4.GIT