]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://repo.or.cz/factor/jcg
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 31 Aug 2008 08:09:23 +0000 (03:09 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 31 Aug 2008 08:09:23 +0000 (03:09 -0500)
basis/cocoa/views/views.factor
extra/math/blas/matrices/matrices-docs.factor
extra/math/blas/matrices/matrices.factor
extra/math/blas/vectors/vectors-docs.factor
extra/math/blas/vectors/vectors.factor

index ca631d5deab2bb1c88edb5d04e595eb8b250a0d7..8bfbe330b279f25b6a2a3d5123c196ac0cf28e80 100644 (file)
@@ -21,6 +21,10 @@ IN: cocoa.views
 : NSOpenGLPFASampleBuffers 55 ;
 : NSOpenGLPFASamples 56 ;
 : NSOpenGLPFAAuxDepthStencil 57 ;
+: NSOpenGLPFAColorFloat  58 ;
+: NSOpenGLPFAMultisample 59 ;
+: NSOpenGLPFASupersample 60 ;
+: NSOpenGLPFASampleAlpha 61 ;
 : NSOpenGLPFARendererID 70 ;
 : NSOpenGLPFASingleRenderer 71 ;
 : NSOpenGLPFANoRecovery 72 ;
@@ -34,25 +38,36 @@ IN: cocoa.views
 : NSOpenGLPFACompliant 83 ;
 : NSOpenGLPFAScreenMask 84 ;
 : NSOpenGLPFAPixelBuffer 90 ;
+: NSOpenGLPFAAllowOfflineRenderers 96 ;
 : NSOpenGLPFAVirtualScreenCount 128 ;
 
+: kCGLRendererGenericFloatID HEX: 00020400 ;
+
 <PRIVATE
 
 SYMBOL: +software-renderer+
+SYMBOL: +multisample+
 
 PRIVATE>
 
 : with-software-renderer ( quot -- )
-    t +software-renderer+ set
-    [ f +software-renderer+ set ]
-    [ ] cleanup ; inline
+    t +software-renderer+ pick with-variable ; inline
+: with-multisample ( quot -- )
+    t +multisample+ pick with-variable ; inline
 
 : <PixelFormat> ( -- pixelfmt )
     NSOpenGLPixelFormat -> alloc [
         NSOpenGLPFAWindow ,
         NSOpenGLPFADoubleBuffer ,
         NSOpenGLPFADepthSize , 16 ,
-        +software-renderer+ get [ NSOpenGLPFARobust , ] when
+        +software-renderer+ get [
+            NSOpenGLPFARendererID , kCGLRendererGenericFloatID ,
+        ] when
+        +multisample+ get [
+            NSOpenGLPFASupersample ,
+            NSOpenGLPFASampleBuffers , 1 ,
+            NSOpenGLPFASamples , 8 ,
+        ] when
         0 ,
     ] { } make >c-int-array
     -> initWithAttributes:
index ddd72a4a391cfa0fd2a66b483602ef503f2be141..dc6a86017ab9206fdcc0c3fa61470729707b5a69 100644 (file)
@@ -1,4 +1,4 @@
-USING: alien byte-arrays help.markup help.syntax math.blas.vectors sequences ;
+USING: alien byte-arrays help.markup help.syntax math math.blas.vectors sequences strings ;
 IN: math.blas.matrices
 
 ARTICLE: "math.blas-summary" "Basic Linear Algebra Subroutines (BLAS) interface"
@@ -52,13 +52,13 @@ ARTICLE: "math.blas.matrices" "BLAS interface matrix operations"
 { $subsection Mcols }
 { $subsection Msub }
 "Matrix-vector products:"
-{ $subsection n*M.V+n*V-in-place }
+{ $subsection n*M.V+n*V! }
 { $subsection n*M.V+n*V }
 { $subsection n*M.V }
 { $subsection M.V }
 "Vector outer products:"
-{ $subsection n*V(*)V+M-in-place }
-{ $subsection n*V(*)Vconj+M-in-place }
+{ $subsection n*V(*)V+M! }
+{ $subsection n*V(*)Vconj+M! }
 { $subsection n*V(*)V+M }
 { $subsection n*V(*)Vconj+M }
 { $subsection n*V(*)V }
@@ -66,12 +66,12 @@ ARTICLE: "math.blas.matrices" "BLAS interface matrix operations"
 { $subsection V(*) }
 { $subsection V(*)conj }
 "Matrix products:"
-{ $subsection n*M.M+n*M-in-place }
+{ $subsection n*M.M+n*M! }
 { $subsection n*M.M+n*M }
 { $subsection n*M.M }
 { $subsection M. }
 "Scalar-matrix products:"
-{ $subsection n*M-in-place }
+{ $subsection n*M! }
 { $subsection n*M }
 { $subsection M*n }
 { $subsection M/n } ;
@@ -111,134 +111,135 @@ HELP: double-complex-blas-matrix
 } related-words
 
 HELP: Mwidth
-{ $values { "matrix" "a BLAS matrix inherited from " { $link blas-matrix-base } } { "width" "The number of columns" } }
+{ $values { "matrix" blas-matrix-base } { "width" integer } }
 { $description "Returns the number of columns in " { $snippet "matrix" } "." } ;
 
 HELP: Mheight
-{ $values { "matrix" "a BLAS matrix inherited from " { $link blas-matrix-base } } { "width" "The number of columns" } }
+{ $values { "matrix" blas-matrix-base } { "height" integer } }
 { $description "Returns the number of rows in " { $snippet "matrix" } "." } ;
 
 { Mwidth Mheight } related-words
 
-HELP: n*M.V+n*V-in-place
-{ $values { "alpha" "a number" } { "A" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } { "x" "an N-element BLAS vector inherited from " { $link blas-vector-base } } { "beta" "a number" } { "y" "an M-element BLAS vector inherited from " { $link blas-vector-base } } }
+HELP: n*M.V+n*V!
+{ $values { "alpha" number } { "A" blas-matrix-base } { "x" blas-vector-base } { "beta" number } { "y" blas-vector-base } { "y=alpha*A.x+b*y" blas-vector-base } }
 { $description "Calculate the matrix-vector product " { $snippet "αAx + βy" } ", and overwrite the current contents of " { $snippet "y" } " with the result. The width of " { $snippet "A" } " must match the length of " { $snippet "x" } ", and the height must match the length of " { $snippet "y" } ". Corresponds to the xGEMV routines in BLAS." }
 { $side-effects "y" } ;
 
-HELP: n*V(*)V+M-in-place
-{ $values { "alpha" "a number" } { "x" "an M-element BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element BLAS vector inherited from " { $link blas-vector-base } } { "A" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } }
+HELP: n*V(*)V+M!
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "A" blas-matrix-base } { "A=alpha*x(*)y+A" blas-matrix-base } }
 { $description "Calculate the outer product " { $snippet "αx⊗y + A" } " and overwrite the current contents of A with the result. The width of " { $snippet "A" } " must match the length of " { $snippet "y" } ", and its height must match the length of " { $snippet "x" } ". Corresponds to the xGER and xGERU routines in BLAS." }
 { $side-effects "A" } ;
 
-HELP: n*V(*)Vconj+M-in-place
-{ $values { "alpha" "a number" } { "x" "an M-element complex BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element complex BLAS vector inherited from " { $link blas-vector-base } } { "A" "an M-row, N-column complex BLAS matrix inherited from " { $link blas-matrix-base } } }
+HELP: n*V(*)Vconj+M!
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "A" blas-matrix-base } { "A=alpha*x(*)yconj+A" blas-matrix-base } }
 { $description "Calculate the conjugate outer product " { $snippet "αx⊗y̅ + A" } " and overwrite the current contents of A with the result. The width of " { $snippet "A" } " must match the length of " { $snippet "y" } ", and its height must match the length of " { $snippet "x" } ". Corresponds to the xGERC routines in BLAS." }
 { $side-effects "A" } ;
 
-HELP: n*M.M+n*M-in-place
-{ $values { "alpha" "a number" } { "A" "an M-row, K-column BLAS matrix inherited from " { $link blas-matrix-base } } { "B" "a K-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } { "beta" "a number" } { "C" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } }
-{ $description "Calculate the matrix product " { $snippet "αAB + βC" } " and overwrite the current contents of C with the result. The width of " { $snippet "A" } " and the height of " { $snippet "B" } " must match, as must the heights of " { $snippet "A" } " and " { $snippet "C" } ", and the widths of " { $snippet "B" } " and " { $snippet "C" } ". Corresponds to the xGEMM routines in BLAS." } ;
+HELP: n*M.M+n*M!
+{ $values { "alpha" number } { "A" blas-matrix-base } { "B" blas-matrix-base } { "beta" number } { "C" blas-matrix-base } { "C=alpha*A.B+beta*C" blas-matrix-base } }
+{ $description "Calculate the matrix product " { $snippet "αAB + βC" } " and overwrite the current contents of C with the result. The width of " { $snippet "A" } " and the height of " { $snippet "B" } " must match, as must the heights of " { $snippet "A" } " and " { $snippet "C" } ", and the widths of " { $snippet "B" } " and " { $snippet "C" } ". Corresponds to the xGEMM routines in BLAS." }
+{ $side-effects "C" } ;
 
 HELP: <empty-matrix>
-{ $values { "rows" "the number of rows the new matrix will have" } { "cols" "the number of columns the new matrix will have" } { "exemplar" "A BLAS vector inherited from " { $link blas-vector-base } " or BLAS matrix inherited from " { $link blas-matrix-base } } }
+{ $values { "rows" integer } { "cols" integer } { "exemplar" blas-vector-base blas-matrix-base } { "matrix" blas-matrix-base } }
 { $description "Create a matrix of all zeros with the given dimensions and the same element type as " { $snippet "exemplar" } "." } ;
 
 { <zero-vector> <empty-vector> <empty-matrix> } related-words
 
 HELP: n*M.V+n*V
-{ $values { "alpha" "a number" } { "A" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } { "x" "an N-element BLAS vector inherited from " { $link blas-vector-base } } { "beta" "a number" } { "y" "an M-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "alpha" number } { "A" blas-matrix-base } { "x" blas-vector-base } { "beta" number } { "y" blas-vector-base } { "alpha*A.x+b*y" blas-vector-base } }
 { $description "Calculate the matrix-vector product " { $snippet "αAx + βy" } " and return a freshly allocated vector containing the result. The width of " { $snippet "A" } " must match the length of " { $snippet "x" } ", and the height must match the length of " { $snippet "y" } ". The returned vector will have the same length as " { $snippet "y" } ". Corresponds to the xGEMV routines in BLAS." } ;
 
 HELP: n*V(*)V+M
-{ $values { "alpha" "a number" } { "x" "an M-element BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element BLAS vector inherited from " { $link blas-vector-base } } { "A" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } }
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "A" blas-matrix-base } { "alpha*x(*)y+A" blas-matrix-base } }
 { $description "Calculate the outer product " { $snippet "αx⊗y + A" } " and return a freshly allocated matrix containing the result. The width of " { $snippet "A" } " must match the length of " { $snippet "y" } ", and its height must match the length of " { $snippet "x" } ". The returned matrix will have the same dimensions as " { $snippet "A" } ". Corresponds to the xGER and xGERU routines in BLAS." } ;
 
 HELP: n*V(*)Vconj+M
-{ $values { "alpha" "a number" } { "x" "an M-element complex BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element complex BLAS vector inherited from " { $link blas-vector-base } } { "A" "an M-row, N-column complex BLAS matrix inherited from " { $link blas-matrix-base } } }
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "A" blas-matrix-base } { "alpha*x(*)yconj+A" blas-matrix-base } }
 { $description "Calculate the conjugate outer product " { $snippet "αx⊗y̅ + A" } " and return a freshly allocated matrix containing the result. The width of " { $snippet "A" } " must match the length of " { $snippet "y" } ", and its height must match the length of " { $snippet "x" } ". The returned matrix will have the same dimensions as " { $snippet "A" } ". Corresponds to the xGERC routines in BLAS." } ;
 
 HELP: n*M.M+n*M
-{ $values { "alpha" "a number" } { "A" "an M-row, K-column BLAS matrix inherited from " { $link blas-matrix-base } } { "B" "a K-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } { "beta" "a number" } { "C" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } }
+{ $values { "alpha" number } { "A" blas-matrix-base } { "B" blas-matrix-base } { "beta" number } { "C" blas-matrix-base } { "alpha*A.B+beta*C" blas-matrix-base } }
 { $description "Calculate the matrix product " { $snippet "αAB + βC" } " and overwrite the current contents of C with the result. The width of " { $snippet "A" } " and the height of " { $snippet "B" } " must match, as must the heights of " { $snippet "A" } " and " { $snippet "C" } ", and the widths of " { $snippet "B" } " and " { $snippet "C" } ". Corresponds to the xGEMM routines in BLAS." } ;
 
 HELP: n*M.V
-{ $values { "alpha" "a number" } { "A" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } { "x" "an N-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "alpha" number } { "A" blas-matrix-base } { "x" blas-vector-base } { "alpha*A.x" blas-vector-base } }
 { $description "Calculate the matrix-vector product " { $snippet "αAx" } " and return a freshly allocated vector containing the result. The width of " { $snippet "A" } " must match the length of " { $snippet "x" } ". The length of the returned vector will match the height of " { $snippet "A" } ". Corresponds to the xGEMV routines in BLAS." } ;
 
 HELP: M.V
-{ $values { "A" "an M-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } { "x" "an N-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "A" blas-matrix-base } { "x" blas-vector-base } { "A.x" blas-vector-base } }
 { $description "Calculate the matrix-vector product " { $snippet "Ax" } " and return a freshly allocated vector containing the result. The width of " { $snippet "A" } " must match the length of " { $snippet "x" } ". The length of the returned vector will match the height of " { $snippet "A" } ". Corresponds to the xGEMV routines in BLAS." } ;
 
-{ n*M.V+n*V-in-place n*M.V+n*V n*M.V M.V } related-words
+{ n*M.V+n*V! n*M.V+n*V n*M.V M.V } related-words
 
 HELP: n*V(*)V
-{ $values { "alpha" "a number" } { "x" "an M-element BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "alpha*x(*)y" blas-matrix-base } }
 { $description "Calculate the outer product " { $snippet "αx⊗y" } " and return a freshly allocated matrix containing the result. The returned matrix's height will match the length of " { $snippet "x" } ", and its width will match the length of " { $snippet "y" } ". Corresponds to the xGER and xGERU routines in BLAS." } ;
 
 HELP: n*V(*)Vconj
-{ $values { "alpha" "a number" } { "x" "an M-element BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "alpha*x(*)yconj" blas-matrix-base } }
 { $description "Calculate the outer product " { $snippet "αx⊗y̅" } " and return a freshly allocated matrix containing the result. The returned matrix's height will match the length of " { $snippet "x" } ", and its width will match the length of " { $snippet "y" } ". Corresponds to the xGERC routines in BLAS." } ;
 
 HELP: V(*)
-{ $values { "x" "an M-element BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "x(*)y" blas-matrix-base } }
 { $description "Calculate the outer product " { $snippet "x⊗y" } " and return a freshly allocated matrix containing the result. The returned matrix's height will match the length of " { $snippet "x" } ", and its width will match the length of " { $snippet "y" } ". Corresponds to the xGER and xGERU routines in BLAS." } ;
 
 HELP: V(*)conj
-{ $values { "x" "an M-element BLAS vector inherited from " { $link blas-vector-base } } { "y" "an N-element BLAS vector inherited from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "x(*)yconj" blas-matrix-base } }
 { $description "Calculate the conjugate outer product " { $snippet "x⊗y̅" } " and return a freshly allocated matrix containing the result. The returned matrix's height will match the length of " { $snippet "x" } ", and its width will match the length of " { $snippet "y" } ". Corresponds to the xGERC routines in BLAS." } ;
 
-{ n*V(*)V+M-in-place n*V(*)Vconj+M-in-place n*V(*)V+M n*V(*)Vconj+M n*V(*)V n*V(*)Vconj V(*) V(*)conj V. V.conj } related-words
+{ n*V(*)V+M! n*V(*)Vconj+M! n*V(*)V+M n*V(*)Vconj+M n*V(*)V n*V(*)Vconj V(*) V(*)conj V. V.conj } related-words
 
 HELP: n*M.M
-{ $values { "alpha" "a number" } { "A" "an M-row, K-column BLAS matrix inherited from " { $link blas-matrix-base } } { "B" "a K-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } }
+{ $values { "alpha" number } { "A" blas-matrix-base } { "B" blas-matrix-base } { "alpha*A.B" blas-matrix-base } }
 { $description "Calculate the matrix product " { $snippet "αAB" } " and return a freshly allocated matrix containing the result. The width of " { $snippet "A" } " and the height of " { $snippet "B" } " must match. The returned matrix's height will be the same as " { $snippet "A" } "'s, and its width will match " { $snippet "B" } "'s. Corresponds to the xGEMM routines in BLAS." } ;
 
 HELP: M.
-{ $values { "A" "an M-row, K-column BLAS matrix inherited from " { $link blas-matrix-base } } { "B" "a K-row, N-column BLAS matrix inherited from " { $link blas-matrix-base } } }
+{ $values { "A" blas-matrix-base } { "B" blas-matrix-base } { "A.B" blas-matrix-base } }
 { $description "Calculate the matrix product " { $snippet "AB" } " and return a freshly allocated matrix containing the result. The width of " { $snippet "A" } " and the height of " { $snippet "B" } " must match. The returned matrix's height will be the same as " { $snippet "A" } "'s, and its width will match " { $snippet "B" } "'s. Corresponds to the xGEMM routines in BLAS." } ;
 
-{ n*M.M+n*M-in-place n*M.M+n*M n*M.M M. } related-words
+{ n*M.M+n*M! n*M.M+n*M n*M.M M. } related-words
 
 HELP: Msub
-{ $values { "matrix" "A BLAS matrix inheriting from " { $link blas-matrix-base } } { "row" "The topmost row of the slice" } { "col" "The leftmost column of the slice" } { "height" "The height of the slice" } { "width" "The width of the slice" } }
+{ $values { "matrix" blas-matrix-base } { "row" integer } { "col" integer } { "height" integer } { "width" integer } { "sub" blas-matrix-base } }
 { $description "Select a rectangular submatrix of " { $snippet "matrix" } " with the given dimensions. The returned submatrix will share the parent matrix's storage." } ;
 
 HELP: Mrows
-{ $values { "matrix" "A BLAS matrix inheriting from " { $link blas-matrix-base } } }
+{ $values { "A" blas-matrix-base } { "rows" sequence } }
 { $description "Return a sequence of BLAS vectors representing the rows of " { $snippet "matrix" } ". Each vector will share the parent matrix's storage." } ;
 
 HELP: Mcols
-{ $values { "matrix" "A BLAS matrix inheriting from " { $link blas-matrix-base } } }
+{ $values { "A" blas-matrix-base } { "cols" sequence } }
 { $description "Return a sequence of BLAS vectors representing the columns of " { $snippet "matrix" } ". Each vector will share the parent matrix's storage." } ;
 
-HELP: n*M-in-place
-{ $values { "n" "a number" } { "A" "A BLAS matrix inheriting from " { $link blas-matrix-base } } }
+HELP: n*M!
+{ $values { "n" number } { "A" blas-matrix-base } { "A=n*A" blas-matrix-base } }
 { $description "Calculate the scalar-matrix product " { $snippet "nA" } " and overwrite the current contents of A with the result." }
 { $side-effects "A" } ;
 
 HELP: n*M
-{ $values { "n" "a number" } { "A" "A BLAS matrix inheriting from " { $link blas-matrix-base } } }
+{ $values { "n" number } { "A" blas-matrix-base } { "n*A" blas-matrix-base } }
 { $description "Calculate the scalar-matrix product " { $snippet "nA" } " and return a freshly allocated matrix with the same dimensions as " { $snippet "A" } " containing the result." } ;
 
 HELP: M*n
-{ $values { "A" "A BLAS matrix inheriting from " { $link blas-matrix-base } } { "n" "a number" } }
+{ $values { "A" blas-matrix-base } { "n" number } { "A*n" blas-matrix-base } }
 { $description "Calculate the scalar-matrix product " { $snippet "nA" } " and return a freshly allocated matrix with the same dimensions as " { $snippet "A" } " containing the result." } ;
 
 HELP: M/n
-{ $values { "A" "A BLAS matrix inheriting from " { $link blas-matrix-base } } { "n" "a number" } }
+{ $values { "A" blas-matrix-base } { "n" number } { "A/n" blas-matrix-base } }
 { $description "Calculate the scalar-matrix product " { $snippet "(1/n)A" } " and return a freshly allocated matrix with the same dimensions as " { $snippet "A" } " containing the result." } ;
 
-{ n*M-in-place n*M M*n M/n } related-words
+{ n*M! n*M M*n M/n } related-words
 
 HELP: Mtranspose
-{ $values { "matrix" "A BLAS matrix inheriting from " { $link blas-matrix-base } } }
+{ $values { "matrix" blas-matrix-base } { "matrix^T" blas-matrix-base } }
 { $description "Returns the transpose of " { $snippet "matrix" } ". The returned matrix shares storage with the original matrix." } ;
 
 HELP: element-type
-{ $values { "v" "a BLAS vector inheriting from " { $link blas-vector-base } ", or a BLAS matrix inheriting from " { $link blas-matrix-base } } }
+{ $values { "v" blas-vector-base blas-matrix-base } { "type" string } }
 { $description "Return the C type of the elements in the given BLAS vector or matrix." } ;
 
 HELP: <empty-vector>
-{ $values { "length" "The length of the new vector" } { "exemplar" "a BLAS vector inheriting from " { $link blas-vector-base } ", or a BLAS matrix inheriting from " { $link blas-matrix-base } } }
-{ $description "Return a vector of zeros with the given length and the same element type as " { $snippet "v" } "." } ;
+{ $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" } "." } ;
 
index c8e55c4ec0c54e91cce4bbbf2ee6c87aefde79f0..4f50543e73ed479010b323b8a5164e4e06c22c81 100755 (executable)
@@ -153,41 +153,45 @@ PRIVATE>
     [ (flatten-complex-sequence) >c-double-array ] (>matrix)
     <double-complex-blas-matrix> ;
 
-GENERIC: n*M.V+n*V-in-place ( alpha A x beta y -- y=alpha*A.x+b*y )
-GENERIC: n*V(*)V+M-in-place ( alpha x y A -- A=alpha*x(*)y+A )
-GENERIC: n*V(*)Vconj+M-in-place ( alpha x y A -- A=alpha*x(*)yconj+A )
-GENERIC: n*M.M+n*M-in-place ( alpha A B beta C -- C=alpha*A.B+beta*C )
+GENERIC: n*M.V+n*V! ( alpha A x beta y -- y=alpha*A.x+b*y )
+GENERIC: n*V(*)V+M! ( alpha x y A -- A=alpha*x(*)y+A )
+GENERIC: n*V(*)Vconj+M! ( alpha x y A -- A=alpha*x(*)yconj+A )
+GENERIC: n*M.M+n*M! ( alpha A B beta C -- C=alpha*A.B+beta*C )
 
-METHOD: n*M.V+n*V-in-place { real float-blas-matrix float-blas-vector real float-blas-vector }
+METHOD: n*M.V+n*V! { real float-blas-matrix float-blas-vector real float-blas-vector }
     [ ] (prepare-gemv) [ cblas_sgemv ] dip ;
-METHOD: n*M.V+n*V-in-place { real double-blas-matrix double-blas-vector real double-blas-vector }
+METHOD: n*M.V+n*V! { real double-blas-matrix double-blas-vector real double-blas-vector }
     [ ] (prepare-gemv) [ cblas_dgemv ] dip ;
-METHOD: n*M.V+n*V-in-place { number float-complex-blas-matrix float-complex-blas-vector number float-complex-blas-vector }
+METHOD: n*M.V+n*V! { number float-complex-blas-matrix float-complex-blas-vector number float-complex-blas-vector }
     [ (>c-complex) ] (prepare-gemv) [ cblas_cgemv ] dip ;
-METHOD: n*M.V+n*V-in-place { number double-complex-blas-matrix double-complex-blas-vector number double-complex-blas-vector }
+METHOD: n*M.V+n*V! { number double-complex-blas-matrix double-complex-blas-vector number double-complex-blas-vector }
     [ (>z-complex) ] (prepare-gemv) [ cblas_zgemv ] dip ;
 
-METHOD: n*V(*)V+M-in-place { real float-blas-vector float-blas-vector float-blas-matrix }
+METHOD: n*V(*)V+M! { real float-blas-vector float-blas-vector float-blas-matrix }
     [ ] (prepare-ger) [ cblas_sger ] dip ;
-METHOD: n*V(*)V+M-in-place { real double-blas-vector double-blas-vector double-blas-matrix }
+METHOD: n*V(*)V+M! { real double-blas-vector double-blas-vector double-blas-matrix }
     [ ] (prepare-ger) [ cblas_dger ] dip ;
-METHOD: n*V(*)V+M-in-place { number float-complex-blas-vector float-complex-blas-vector float-complex-blas-matrix }
+METHOD: n*V(*)V+M! { number float-complex-blas-vector float-complex-blas-vector float-complex-blas-matrix }
     [ (>c-complex) ] (prepare-ger) [ cblas_cgeru ] dip ;
-METHOD: n*V(*)V+M-in-place { number double-complex-blas-vector double-complex-blas-vector double-complex-blas-matrix }
+METHOD: n*V(*)V+M! { number double-complex-blas-vector double-complex-blas-vector double-complex-blas-matrix }
     [ (>z-complex) ] (prepare-ger) [ cblas_zgeru ] dip ;
 
-METHOD: n*V(*)Vconj+M-in-place { number float-complex-blas-vector float-complex-blas-vector float-complex-blas-matrix }
+METHOD: n*V(*)Vconj+M! { real float-blas-vector float-blas-vector float-blas-matrix }
+    [ ] (prepare-ger) [ cblas_sger ] dip ;
+METHOD: n*V(*)Vconj+M! { real double-blas-vector double-blas-vector double-blas-matrix }
+    [ ] (prepare-ger) [ cblas_dger ] dip ;
+METHOD: n*V(*)Vconj+M! { number float-complex-blas-vector float-complex-blas-vector float-complex-blas-matrix }
     [ (>c-complex) ] (prepare-ger) [ cblas_cgerc ] dip ;
-METHOD: n*V(*)Vconj+M-in-place { number double-complex-blas-vector double-complex-blas-vector double-complex-blas-matrix }
+METHOD: n*V(*)Vconj+M! { number double-complex-blas-vector double-complex-blas-vector double-complex-blas-matrix }
     [ (>z-complex) ] (prepare-ger) [ cblas_zgerc ] dip ;
 
-METHOD: n*M.M+n*M-in-place { real float-blas-matrix float-blas-matrix real float-blas-matrix }
+METHOD: n*M.M+n*M! { real float-blas-matrix float-blas-matrix real float-blas-matrix }
     [ ] (prepare-gemm) [ cblas_sgemm ] dip ;
-METHOD: n*M.M+n*M-in-place { real double-blas-matrix double-blas-matrix real double-blas-matrix }
+METHOD: n*M.M+n*M! { real double-blas-matrix double-blas-matrix real double-blas-matrix }
     [ ] (prepare-gemm) [ cblas_dgemm ] dip ;
-METHOD: n*M.M+n*M-in-place { number float-complex-blas-matrix float-complex-blas-matrix number float-complex-blas-matrix }
+METHOD: n*M.M+n*M! { number float-complex-blas-matrix float-complex-blas-matrix number float-complex-blas-matrix }
     [ (>c-complex) ] (prepare-gemm) [ cblas_cgemm ] dip ;
-METHOD: n*M.M+n*M-in-place { number double-complex-blas-matrix double-complex-blas-matrix number double-complex-blas-matrix }
+METHOD: n*M.M+n*M! { number double-complex-blas-matrix double-complex-blas-matrix number double-complex-blas-matrix }
     [ (>z-complex) ] (prepare-gemm) [ cblas_zgemm ] dip ;
 
 ! XXX should do a dense clone
@@ -206,36 +210,36 @@ syntax:M: blas-matrix-base clone
     [ f swap (blas-matrix-like) ] 3tri ;
 
 : n*M.V+n*V ( alpha A x beta y -- alpha*A.x+b*y )
-    clone n*M.V+n*V-in-place ;
+    clone n*M.V+n*V! ;
 : n*V(*)V+M ( alpha x y A -- alpha*x(*)y+A )
-    clone n*V(*)V+M-in-place ;
+    clone n*V(*)V+M! ;
 : n*V(*)Vconj+M ( alpha x y A -- alpha*x(*)yconj+A )
-    clone n*V(*)Vconj+M-in-place ;
+    clone n*V(*)Vconj+M! ;
 : n*M.M+n*M ( alpha A B beta C -- alpha*A.B+beta*C )
-    clone n*M.M+n*M-in-place ;
+    clone n*M.M+n*M! ;
 
 : n*M.V ( alpha A x -- alpha*A.x )
     1.0 2over [ Mheight ] dip <empty-vector>
-    n*M.V+n*V-in-place ; inline
+    n*M.V+n*V! ; inline
 
 : M.V ( A x -- A.x )
     1.0 -rot n*M.V ; inline
 
-: n*V(*)V ( n x y -- n*x(*)y )
+: n*V(*)V ( alpha x y -- alpha*x(*)y )
     2dup [ length>> ] bi@ pick <empty-matrix>
-    n*V(*)V+M-in-place ;
-: n*V(*)Vconj ( n x y -- n*x(*)yconj )
+    n*V(*)V+M! ;
+: n*V(*)Vconj ( alpha x y -- alpha*x(*)yconj )
     2dup [ length>> ] bi@ pick <empty-matrix>
-    n*V(*)Vconj+M-in-place ;
+    n*V(*)Vconj+M! ;
 
 : V(*) ( x y -- x(*)y )
     1.0 -rot n*V(*)V ; inline
 : V(*)conj ( x y -- x(*)yconj )
     1.0 -rot n*V(*)Vconj ; inline
 
-: n*M.M ( n A B -- n*A.B )
+: n*M.M ( alpha A B -- alpha*A.B )
     2dup [ Mheight ] [ Mwidth ] bi* pick <empty-matrix> 
-    1.0 swap n*M.M+n*M-in-place ;
+    1.0 swap n*M.M+n*M! ;
 
 : M. ( A B -- A.B )
     1.0 -rot n*M.M ; inline
@@ -247,7 +251,7 @@ syntax:M: blas-matrix-base clone
     height
     width ;
 
-: Msub ( matrix row col height width -- submatrix )
+: Msub ( matrix row col height width -- sub )
     5 npick dup transpose>>
     [ nip [ [ swap ] 2dip swap ] when (Msub) ] 2keep
     swap (blas-matrix-like) ;
@@ -281,14 +285,14 @@ syntax:M: blas-matrix-rowcol-sequence nth-unsafe
 
 : Mrows ( A -- rows )
     dup transpose>> [ (Mcols) ] [ (Mrows) ] if ;
-: Mcols ( A -- rows )
+: Mcols ( A -- cols )
     dup transpose>> [ (Mrows) ] [ (Mcols) ] if ;
 
-: n*M-in-place ( n A -- A=n*A )
-    [ (Mcols) [ n*V-in-place drop ] with each ] keep ;
+: n*M! ( n A -- A=n*A )
+    [ (Mcols) [ n*V! drop ] with each ] keep ;
 
 : n*M ( n A -- n*A )
-    clone n*M-in-place ; inline
+    clone n*M! ; inline
 
 : M*n ( A n -- A*n )
     swap n*M ; inline
index 4fad9c73781963a32cf5f130dbd4cf4d85dca53b..0595f0098916bd36df030bd4eb97ca0a731a2ab9 100644 (file)
@@ -1,4 +1,4 @@
-USING: alien byte-arrays help.markup help.syntax sequences ;
+USING: alien byte-arrays help.markup help.syntax math sequences ;
 IN: math.blas.vectors
 
 ARTICLE: "math.blas.vectors" "BLAS interface vector operations"
@@ -11,13 +11,13 @@ ARTICLE: "math.blas.vectors" "BLAS interface vector operations"
 { $subsection Viamax }
 { $subsection Vamax }
 "Scalar-vector products:"
-{ $subsection n*V-in-place }
+{ $subsection n*V! }
 { $subsection n*V }
 { $subsection V*n }
 { $subsection V/n }
 { $subsection Vneg }
 "Vector addition:" 
-{ $subsection n*V+V-in-place }
+{ $subsection n*V+V! }
 { $subsection n*V+V }
 { $subsection V+ }
 { $subsection V- }
@@ -51,81 +51,81 @@ HELP: float-complex-blas-vector
 HELP: double-complex-blas-vector
 { $class-description "A vector of single-precision floating-point complex values. Complex values are stored in memory as two consecutive float values, real part then imaginary part. For details on the tuple layout, see " { $link blas-vector-base } "." } ;
 
-HELP: n*V+V-in-place
-{ $values { "alpha" "a number" } { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+HELP: n*V+V!
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "y=alpha*x+y" blas-vector-base } }
 { $description "Calculate the vector sum " { $snippet "αx + y" } " and replace the existing contents of y with the result. Corresponds to the xAXPY routines in BLAS." }
 { $side-effects "y" } ;
 
-HELP: n*V-in-place
-{ $values { "alpha" "a number" } { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+HELP: n*V!
+{ $values { "alpha" number } { "x" blas-vector-base } { "x=alpha*x" blas-vector-base } }
 { $description "Calculate the scalar-vector product " { $snippet "αx" } " and replace the existing contents of x with the result. Corresponds to the xSCAL routines in BLAS." }
 { $side-effects "x" } ;
 
 HELP: V.
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "x.y" number } }
 { $description "Calculate the inner product " { $snippet "x⋅y" } ". Corresponds to the xDOT and xDOTU routines in BLAS." } ;
 
 HELP: V.conj
-{ $values { "x" "a complex BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a complex BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "xconj.y" number } }
 { $description "Calculate the conjugate inner product " { $snippet "x̅⋅y" } ". Corresponds to the xDOTC routines in BLAS." } ;
 
 HELP: Vnorm
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "norm" number } }
 { $description "Calculate the norm-2, i.e., the magnitude or absolute value, of " { $snippet "x" } " (" { $snippet "‖x‖₂" } "). Corresponds to the xNRM2 routines in BLAS." } ;
 
 HELP: Vasum
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "sum" number } }
 { $description "Calculate the sum of the norm-1s of the elements of " { $snippet "x" } " (" { $snippet "Σ ‖xᵢ‖₁" } "). Corresponds to the xASUM routines in BLAS." } ;
 
 HELP: Vswap
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "x=y" blas-vector-base } { "y=x" blas-vector-base } }
 { $description "Swap the contents of " { $snippet "x" } " and " { $snippet "y" } " in place. Corresponds to the xSWAP routines in BLAS." }
 { $side-effects "x" "y" } ;
 
 HELP: Viamax
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "max-i" integer } }
 { $description "Return the index of the element in " { $snippet "x" } " with the largest norm-1. If more than one element has the same norm-1, returns the smallest index. Corresponds to the IxAMAX routines in BLAS." } ;
 
 HELP: Vamax
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "max" number } }
 { $description "Return the value of the element in " { $snippet "x" } " with the largest norm-1. If more than one element has the same norm-1, returns the first element. Corresponds to the IxAMAX routines in BLAS." } ;
 
 { Viamax Vamax } related-words
 
 HELP: <zero-vector>
-{ $values { "exemplar" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "exemplar" blas-vector-base } { "zero" blas-vector-base } }
 { $description "Return a vector of zeros with the same length and element type as " { $snippet "v" } ". The vector is constructed with an " { $snippet "inc" } " of zero, so it is not suitable for receiving results from BLAS functions; it is intended to be used as a term in other vector calculations. To construct an empty vector that can be used to receive results, see " { $link <empty-vector> } "." } ;
 
 HELP: n*V+V
-{ $values { "alpha" "a number" } { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "alpha" number } { "x" blas-vector-base } { "y" blas-vector-base } { "alpha*x+y" blas-vector-base } }
 { $description "Calculate the vector sum " { $snippet "αx + y" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result. Corresponds to the xAXPY routines in BLAS." } ;
 
 HELP: n*V
-{ $values { "alpha" "a number" } { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "alpha" "a number" } { "x" blas-vector-base } { "alpha*x" blas-vector-base } }
 { $description "Calculate the scalar-vector product " { $snippet "αx" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result. Corresponds to the xSCAL routines in BLAS." } ;
 
 HELP: V+
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "x+y" blas-vector-base } }
 { $description "Calculate the vector sum " { $snippet "x + y" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result. Corresponds to the xAXPY routines in BLAS." } ;
 
 HELP: V-
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
+{ $values { "x" blas-vector-base } { "y" blas-vector-base } { "x-y" blas-vector-base } }
 { $description "Calculate the vector difference " { $snippet "x – y" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result. Corresponds to the xAXPY routines in BLAS." } ;
 
 HELP: Vneg
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "y" "a BLAS vector inheriting from " { $link blas-vector-base } } }
-{ $description "Negate the elements of " { $snippet "x" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " and " { $snippet "y" } " containing the result." } ;
+{ $values { "x" blas-vector-base } { "-x" blas-vector-base } }
+{ $description "Negate the elements of " { $snippet "x" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result." } ;
 
 HELP: V*n
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "alpha" "a number" } }
+{ $values { "x" blas-vector-base } { "alpha" number } { "x*alpha" blas-vector-base } }
 { $description "Calculate the scalar-vector product " { $snippet "αx" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result. Corresponds to the xSCAL routines in BLAS." } ;
 
 HELP: V/n
-{ $values { "x" "a BLAS vector inheriting from " { $link blas-vector-base } } { "alpha" "a number" } }
+{ $values { "x" blas-vector-base } { "alpha" number } { "x/alpha" blas-vector-base } }
 { $description "Calculate the scalar-vector product " { $snippet "(1/α)x" } " and return a freshly-allocated vector with the same length as " { $snippet "x" } " containing the result. Corresponds to the xSCAL routines in BLAS." } ;
 
-{ n*V+V-in-place n*V-in-place n*V+V n*V V+ V- Vneg V*n V/n } related-words
+{ n*V+V! n*V! n*V+V n*V V+ V- Vneg V*n V/n } related-words
 
 HELP: Vsub
-{ $values { "v" "a BLAS vector inheriting from " { $link blas-vector-base } } { "start" "The index of the first element of the slice" } { "length" "The length of the slice" } }
-{ $description "Slice a subvector out of " { $snippet "v" } " with the given length. The subvector will share storage with the parent vector." } ;
+{ $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." } ;
index 18370f12c0f33aa60382d4eedb83d82e4878cca3..87bc6437c31713c1fca027701dc8ceef32159ec9 100755 (executable)
@@ -21,8 +21,8 @@ C: <double-blas-vector> double-blas-vector
 C: <float-complex-blas-vector> float-complex-blas-vector
 C: <double-complex-blas-vector> double-complex-blas-vector
 
-GENERIC: n*V+V-in-place ( alpha x y -- y=alpha*x+y )
-GENERIC: n*V-in-place   ( alpha x -- x=alpha*x )
+GENERIC: n*V+V! ( alpha x y -- y=alpha*x+y )
+GENERIC: n*V!   ( alpha x -- x=alpha*x )
 
 GENERIC: V. ( x y -- x.y )
 GENERIC: V.conj ( x y -- xconj.y )
@@ -202,30 +202,30 @@ METHOD: Vswap { float-complex-blas-vector float-complex-blas-vector }
 METHOD: Vswap { double-complex-blas-vector double-complex-blas-vector }
     (prepare-swap) [ cblas_zswap ] 2dip ;
 
-METHOD: n*V+V-in-place { real float-blas-vector float-blas-vector }
+METHOD: n*V+V! { real float-blas-vector float-blas-vector }
     (prepare-axpy) [ cblas_saxpy ] dip ;
-METHOD: n*V+V-in-place { real double-blas-vector double-blas-vector }
+METHOD: n*V+V! { real double-blas-vector double-blas-vector }
     (prepare-axpy) [ cblas_daxpy ] dip ;
-METHOD: n*V+V-in-place { number float-complex-blas-vector float-complex-blas-vector }
+METHOD: n*V+V! { number float-complex-blas-vector float-complex-blas-vector }
     [ (>c-complex) ] 2dip
     (prepare-axpy) [ cblas_caxpy ] dip ;
-METHOD: n*V+V-in-place { number double-complex-blas-vector double-complex-blas-vector }
+METHOD: n*V+V! { number double-complex-blas-vector double-complex-blas-vector }
     [ (>z-complex) ] 2dip
     (prepare-axpy) [ cblas_zaxpy ] dip ;
 
-METHOD: n*V-in-place { real float-blas-vector }
+METHOD: n*V! { real float-blas-vector }
     (prepare-scal) [ cblas_sscal ] dip ;
-METHOD: n*V-in-place { real double-blas-vector }
+METHOD: n*V! { real double-blas-vector }
     (prepare-scal) [ cblas_dscal ] dip ;
-METHOD: n*V-in-place { number float-complex-blas-vector }
+METHOD: n*V! { number float-complex-blas-vector }
     [ (>c-complex) ] dip
     (prepare-scal) [ cblas_cscal ] dip ;
-METHOD: n*V-in-place { number double-complex-blas-vector }
+METHOD: n*V! { number double-complex-blas-vector }
     [ (>z-complex) ] dip
     (prepare-scal) [ cblas_zscal ] dip ;
 
-: n*V+V ( alpha x y -- alpha*x+y ) clone n*V+V-in-place ; inline
-: n*V ( alpha x -- alpha*x ) clone n*V-in-place ; inline
+: n*V+V ( alpha x y -- alpha*x+y ) clone n*V+V! ; inline
+: n*V ( alpha x -- alpha*x ) clone n*V! ; inline
 
 : V+ ( x y -- x+y )
     1.0 -rot n*V+V ; inline
@@ -251,6 +251,10 @@ METHOD: V. { double-complex-blas-vector double-complex-blas-vector }
     (prepare-dot)
     "CBLAS_Z" <c-object> [ cblas_zdotu_sub ] keep (z-complex>) ;
 
+METHOD: V.conj { float-blas-vector float-blas-vector }
+    (prepare-dot) cblas_sdot ;
+METHOD: V.conj { double-blas-vector double-blas-vector }
+    (prepare-dot) cblas_ddot ;
 METHOD: V.conj { float-complex-blas-vector float-complex-blas-vector }
     (prepare-dot)
     "CBLAS_C" <c-object> [ cblas_cdotc_sub ] keep (c-complex>) ;
@@ -288,7 +292,7 @@ METHOD: Viamax { double-complex-blas-vector }
 : Vamax ( x -- max )
     [ Viamax ] keep nth ; inline
 
-: Vsub ( v start length -- vsub )
+: Vsub ( v start length -- sub )
     rot [
         [
             nip [ inc>> ] [ element-type heap-size ] [ data>> ] tri