function to convert rect to vect[vect]
Posted: Fri Oct 02, 2009 7:24 am
the following function wo't work right: I dont understand why it will dispay different tpvv
declare rect tp(2,2)
compute tp=||0.7,0.2|0.3,0.8||
declare vect[vect] tpvv(2)
compute tpvv = %rectovv(tp)
disp tpvv(1)
disp tpvv(2)
* result ok
* 0.70000 0.30000
* 0.20000 0.80000
do i=1,2
compute tpvv(i) = ||%ran(1),%ran(1)||
disp tpvv(i)
end do i
*result:
*%RECTOVV2, line 2 Using TPVV as VECTOR(VECTOR)
* 0.47879 1.44596
* 0.47630 0.43394
* question: the warning message means I can't use vector(vector) as parameters?
disp 'tpvv'
do i=1,2
disp tpvv(i)
end do i
******** the following output is totally wrong**************
* tpvv
* %RECTOVV2, line 2 Using TPVV as VECTOR(VECTOR)
* 3.23806e+262 0.43394
* 3.23806e+262 0.43394
* question: why ???????
function %Rectovv m
type vect[vect] %Rectovv
type rect m
local integer nc nr i j
compute nc = %cols(m)
compute nr = %rows(m)
dim %Rectovv(nc)
do i=1,nc
dim %Rectovv(i)(nr)
end do i
do i=1,nc
do j=1,nr
compute %rectovv(i)(j) = m(j,i)
end do j
end do i
end
declare rect tp(2,2)
compute tp=||0.7,0.2|0.3,0.8||
declare vect[vect] tpvv(2)
compute tpvv = %rectovv(tp)
disp tpvv(1)
disp tpvv(2)
* result ok
* 0.70000 0.30000
* 0.20000 0.80000
do i=1,2
compute tpvv(i) = ||%ran(1),%ran(1)||
disp tpvv(i)
end do i
*result:
*%RECTOVV2, line 2 Using TPVV as VECTOR(VECTOR)
* 0.47879 1.44596
* 0.47630 0.43394
* question: the warning message means I can't use vector(vector) as parameters?
disp 'tpvv'
do i=1,2
disp tpvv(i)
end do i
******** the following output is totally wrong**************
* tpvv
* %RECTOVV2, line 2 Using TPVV as VECTOR(VECTOR)
* 3.23806e+262 0.43394
* 3.23806e+262 0.43394
* question: why ???????
function %Rectovv m
type vect[vect] %Rectovv
type rect m
local integer nc nr i j
compute nc = %cols(m)
compute nr = %rows(m)
dim %Rectovv(nc)
do i=1,nc
dim %Rectovv(i)(nr)
end do i
do i=1,nc
do j=1,nr
compute %rectovv(i)(j) = m(j,i)
end do j
end do i
end