remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices

db4
Joe Groff 2009-01-30 11:42:43 -06:00
parent 9d44f16ff6
commit ebf6cbaa0d
13 changed files with 99 additions and 135 deletions

View File

@ -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 IN: math.blas.matrices
ARTICLE: "math.blas-summary" "Basic Linear Algebra Subroutines (BLAS) interface" 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 double-blas-matrix }
{ $subsection float-complex-blas-matrix } { $subsection float-complex-blas-matrix }
{ $subsection double-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:" "There are BOA constructors for all vector and matrix types, which provide the most flexibility in specifying memory layout:"
{ $subsection <float-blas-vector> } { $subsection <float-blas-vector> }
{ $subsection <double-blas-vector> } { $subsection <double-blas-vector> }
@ -74,7 +72,13 @@ ARTICLE: "math.blas.matrices" "BLAS interface matrix operations"
{ $subsection n*M! } { $subsection n*M! }
{ $subsection n*M } { $subsection n*M }
{ $subsection M*n } { $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" ABOUT: "math.blas.matrices"
@ -243,3 +247,43 @@ HELP: <empty-vector>
{ $values { "length" "The length of the new vector" } { "exemplar" blas-vector-base blas-matrix-base } { "vector" blas-vector-base } } { $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" } "." } ; { $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

View File

@ -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 ; sequences tools.test ;
IN: math.blas.matrices.tests IN: math.blas.matrices.tests

View File

@ -4,7 +4,8 @@ math math.blas.cblas math.blas.vectors math.blas.vectors.private
math.complex math.functions math.order functors words math.complex math.functions math.order functors words
sequences sequences.merged sequences.private shuffle sequences sequences.merged sequences.private shuffle
specialized-arrays.direct.float specialized-arrays.direct.double 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 IN: math.blas.matrices
TUPLE: blas-matrix-base underlying ld rows cols transpose ; TUPLE: blas-matrix-base underlying ld rows cols transpose ;
@ -258,6 +259,7 @@ XGERC IS cblas_${T}ger${C}
MATRIX DEFINES ${TYPE}-blas-matrix MATRIX DEFINES ${TYPE}-blas-matrix
<MATRIX> DEFINES <${TYPE}-blas-matrix> <MATRIX> DEFINES <${TYPE}-blas-matrix>
>MATRIX DEFINES >${TYPE}-blas-matrix >MATRIX DEFINES >${TYPE}-blas-matrix
XMATRIX{ DEFINES ${T}matrix{
WHERE WHERE
@ -291,6 +293,11 @@ M: MATRIX n*V(*)Vconj+M!
[ TYPE>ARG ] (prepare-ger) [ TYPE>ARG ] (prepare-ger)
[ XGERC ] dip ; [ XGERC ] dip ;
: XMATRIX{ \ } [ >MATRIX ] parse-literal ; parsing
M: MATRIX pprint-delims
drop \ XMATRIX{ \ } ;
;FUNCTOR ;FUNCTOR
@ -305,3 +312,6 @@ M: MATRIX n*V(*)Vconj+M!
"double-complex" "z" define-complex-blas-matrix "double-complex" "z" define-complex-blas-matrix
>> >>
M: blas-matrix-base >pprint-sequence Mrows ;
M: blas-matrix-base pprint* pprint-object ;

View File

@ -1 +0,0 @@
Joe Groff

View File

@ -1 +0,0 @@
Literal syntax for BLAS vectors and matrices

View File

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

View File

@ -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 ;

View File

@ -1 +0,0 @@
math

View File

@ -23,7 +23,12 @@ ARTICLE: "math.blas.vectors" "BLAS interface vector operations"
{ $subsection V- } { $subsection V- }
"Vector inner products:" "Vector inner products:"
{ $subsection V. } { $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" ABOUT: "math.blas.vectors"
@ -129,3 +134,25 @@ HELP: V/n
HELP: Vsub HELP: Vsub
{ $values { "v" blas-vector-base } { "start" integer } { "length" integer } { "sub" blas-vector-base } } { $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." } ; { $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

View File

@ -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 IN: math.blas.vectors.tests
! clone ! clone

View File

@ -2,7 +2,7 @@ USING: accessors alien alien.c-types arrays byte-arrays combinators
combinators.short-circuit fry kernel math math.blas.cblas combinators.short-circuit fry kernel math math.blas.cblas
math.complex math.functions math.order sequences.complex math.complex math.functions math.order sequences.complex
sequences.complex-components sequences sequences.private 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.float specialized-arrays.double
specialized-arrays.direct.float specialized-arrays.direct.double ; specialized-arrays.direct.float specialized-arrays.direct.double ;
IN: math.blas.vectors IN: math.blas.vectors
@ -138,6 +138,8 @@ VECTOR DEFINES ${TYPE}-blas-vector
<VECTOR> DEFINES <${TYPE}-blas-vector> <VECTOR> DEFINES <${TYPE}-blas-vector>
>VECTOR DEFINES >${TYPE}-blas-vector >VECTOR DEFINES >${TYPE}-blas-vector
XVECTOR{ DEFINES ${T}vector{
WHERE WHERE
TUPLE: VECTOR < blas-vector-base ; TUPLE: VECTOR < blas-vector-base ;
@ -165,6 +167,11 @@ M: VECTOR (blas-direct-array)
[ [ length>> ] [ inc>> ] bi * ] bi [ [ length>> ] [ inc>> ] bi * ] bi
<DIRECT-ARRAY> ; <DIRECT-ARRAY> ;
: XVECTOR{ \ } [ >VECTOR ] parse-literal ; parsing
M: VECTOR pprint-delims
drop \ XVECTOR{ \ } ;
;FUNCTOR ;FUNCTOR
@ -270,3 +277,5 @@ M: VECTOR n*V!
>> >>
M: blas-vector-base >pprint-sequence ;
M: blas-vector-base pprint* pprint-object ;

View File

@ -10,4 +10,3 @@ IN: sequences.squish
: squish-strings ( seq -- seq' ) : squish-strings ( seq -- seq' )
[ { [ sequence? ] [ integer? not ] } 1&& ] "" squish ; [ { [ sequence? ] [ integer? not ] } 1&& ] "" squish ;