some new matrix words
parent
bc5b19fc95
commit
f7889958d9
36
CHANGES.txt
36
CHANGES.txt
|
|
@ -10,11 +10,8 @@ for controlling it:
|
||||||
The compiler now does constant folding for certain words with literal
|
The compiler now does constant folding for certain words with literal
|
||||||
operands. The compiler's peephole optimizer has been improved.
|
operands. The compiler's peephole optimizer has been improved.
|
||||||
|
|
||||||
The alien interface now supports "float" and "double" types.
|
The alien interface now supports "float" and "double" types, and arrays
|
||||||
|
of C types.
|
||||||
Defining a predicate subclass of tuple is supported now. Note that
|
|
||||||
unions and complements over tuples are still not supported. Also,
|
|
||||||
predicate subclasses of concrete tuple classes are not supported either.
|
|
||||||
|
|
||||||
The SO_OOBINLINE socket flag is now set. In 0.74, sending out-of-band
|
The SO_OOBINLINE socket flag is now set. In 0.74, sending out-of-band
|
||||||
data could fill up the buffer and cause a denial-of-service attack.
|
data could fill up the buffer and cause a denial-of-service attack.
|
||||||
|
|
@ -32,33 +29,8 @@ Note that GENERIC: foo is the same as
|
||||||
|
|
||||||
G: foo [ dup ] [ type ] ;
|
G: foo [ dup ] [ type ] ;
|
||||||
|
|
||||||
The seq-each and seq-map words have been renamed to each and map, and
|
Sequence API refactoring, as described in
|
||||||
now work with lists. The each and map words in the lists vocabulary have
|
http://www.jroller.com/page/slava/20050518.
|
||||||
been removed; use the new generic equivalents instead.
|
|
||||||
|
|
||||||
Added two new types of 'virtual' sequences: a range sequence containing
|
|
||||||
a range of integers, and a slice sequence containing a subsequence of
|
|
||||||
another sequence.
|
|
||||||
|
|
||||||
Some string words were made generic, and now work with all sequences:
|
|
||||||
|
|
||||||
Old word: New word:
|
|
||||||
--------- ---------
|
|
||||||
string-head head
|
|
||||||
string-head? head?
|
|
||||||
?string-head ?head
|
|
||||||
string-tail tail
|
|
||||||
vector-tail tail
|
|
||||||
vector-tail* tail*
|
|
||||||
string-tail? tail?
|
|
||||||
?string-tail ?tail
|
|
||||||
substring subseq
|
|
||||||
cat2 append
|
|
||||||
cat3 append3
|
|
||||||
string/ cut
|
|
||||||
string// cut*
|
|
||||||
split1 split1
|
|
||||||
split split
|
|
||||||
|
|
||||||
Factor 0.74:
|
Factor 0.74:
|
||||||
------------
|
------------
|
||||||
|
|
|
||||||
|
|
@ -225,9 +225,13 @@ global [ c-types nest drop ] bind
|
||||||
\ %unbox-double "unbox-op" set
|
\ %unbox-double "unbox-op" set
|
||||||
] "double" define-primitive-type
|
] "double" define-primitive-type
|
||||||
|
|
||||||
: alias-c-type ( old new -- )
|
: (alias-c-type)
|
||||||
c-types get [ >r get r> set ] bind ;
|
c-types get [ >r get r> set ] bind ;
|
||||||
|
|
||||||
|
: alias-c-type ( old new -- )
|
||||||
|
over "*" append over "*" append
|
||||||
|
(alias-c-type) (alias-c-type) ;
|
||||||
|
|
||||||
! FIXME for 64-bit platforms
|
! FIXME for 64-bit platforms
|
||||||
"int" "long" alias-c-type
|
"int" "long" alias-c-type
|
||||||
"uint" "ulong" alias-c-type
|
"uint" "ulong" alias-c-type
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ compile? [
|
||||||
t [
|
t [
|
||||||
"/library/math/constants.factor"
|
"/library/math/constants.factor"
|
||||||
"/library/math/pow.factor"
|
"/library/math/pow.factor"
|
||||||
|
"/library/math/matrices.factor"
|
||||||
"/library/math/trig-hyp.factor"
|
"/library/math/trig-hyp.factor"
|
||||||
"/library/math/arc-trig-hyp.factor"
|
"/library/math/arc-trig-hyp.factor"
|
||||||
"/library/math/random.factor"
|
"/library/math/random.factor"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,17 @@ vectors ;
|
||||||
! : v. ( v v -- x ) 0 swap [ * + ] 2each ;
|
! : v. ( v v -- x ) 0 swap [ * + ] 2each ;
|
||||||
: v. ( v v -- x ) v** 0 swap [ + ] each ;
|
: v. ( v v -- x ) v** 0 swap [ + ] each ;
|
||||||
|
|
||||||
: norm ( v -- a ) dup v. sqrt ;
|
: (cross) ( v1 v2 i1 i2 -- n )
|
||||||
|
rot nth >r swap nth r> * ;
|
||||||
|
|
||||||
|
: cross ( { x1 y1 z1 } { x2 y2 z2 } -- { z1 z2 z3 } )
|
||||||
|
#! Cross product of two 3-dimensional vectors.
|
||||||
|
[
|
||||||
|
2dup 2 1 (cross) >r 2dup 1 2 (cross) r> - ,
|
||||||
|
2dup 0 2 (cross) >r 2dup 2 0 (cross) r> - ,
|
||||||
|
2dup 1 0 (cross) >r 2dup 0 2 (cross) r> - ,
|
||||||
|
2drop
|
||||||
|
] make-vector ;
|
||||||
|
|
||||||
! Matrices
|
! Matrices
|
||||||
! The major dimension is the number of elements per row.
|
! The major dimension is the number of elements per row.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
! Copyright (C) 2005 Slava Pestov.
|
||||||
|
! See http://factor.sf.net/license.txt for BSD license.
|
||||||
|
IN: matrices
|
||||||
|
USING: kernel math ;
|
||||||
|
|
||||||
|
: norm ( v -- a )
|
||||||
|
dup v. sqrt ;
|
||||||
|
|
||||||
|
: normalize ( v -- v )
|
||||||
|
[ norm recip ] keep n*v ;
|
||||||
Loading…
Reference in New Issue