You are here

NArray 0.81

admin의 아바타

홈페이지: http://www.ncnr.nist.gov/staff/nickm/narray.html

NArray: Manipulating multidimensional data in Tcl

NArray is an extension to help Tcl cope with large in-memory numeric arrays. NArray's require only a few more bytes than the storage required by the array. In addition to providing array referencing and setting, narray allows functions to be mapped over each element of the array. These functions are compiled into byte code for performance about 100x faster than straight tcl and only 5-10x slower than C. (These numbers are ball-park figures, actual results depend on the situation.)

% package require narray        ;# load narray package
0.81
% narray create cube 64 64 64   ;# cube is an 64x64x64 float array
cube
% cube status                   ;# 64x64x64 * sizeof(float) = 1MB
 1024.12KB used, debug 0
% cube aref 0 0 0               ;# return the element (0,0,0)
0
% cube aset 0 0 0 10            ;# set (0,0,0) to 10
10
% cube map { [] += 5; }         ;# add 5 to each element
% cube aref 0 0 0               ;# (0,0,0) is now 15
15
% cube vset sum 0               ;# set the variable sum to 0
0
% cube map { sum += $[]; }      ;# sum the elements
% cube vref sum                 ;# get the value of the variable sum
1.31073e+06                     ;# the sum of the elements is 1310730
% expr 64*64*64*5+10            ;# just checking...
1310730
첨부 파일파일 크기
Binary Data narray-0.81.tar.gz61.6 KB
PDF icon NArray Tcl extension.pdf468.28 KB