home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-02 | 947 b | 30 lines | [TEXT/????] |
- NB. numeric utilities
- NB.
- NB. baserep y. in base x.
- NB. clean clean y. to tolerance of 1e_10
- NB. cleanto x. clean y. where x. is tolerance
- NB. groupndx group indices of y. in x.
- NB. range y. is a;b;c range from a to b {in steps of c}
- NB. round round y. to nearest x.
-
- t=. 'baserep clean cleanto groupndx range round'
- SCRIPTNAMES=: t
-
- baserep=: (>:@<.@^. # [) #: ]
- cleanto=: j./"1@((] * (<: |)) +.)
- clean=: 1e_10 & cleanto f.
- round=: ((%&) [.) (<.@+&0.5&.)
-
- NB. groupndx
- NB. Return group indices of elements of y.
- NB. x. is an integer vector of the starting numbers of each group,
- NB. assumed to be in ascending order.
- NB. e.g. 0 0 0 1 1 1 2 2 = 0 3 6 groupndx i.8
- groupndx=: '' : '<: (#x.) }. (+/\r<#x.) r } r=. /: x.,y.'
-
- range=: 0 : 0
- 'xyn'=. 3{.y.,1
- s=. (x<y) { _1 1
- x+s*n*i.>:<.n%~|y-x
- )
-