Re: dimensions issue!



milenko markovic <milenko.markovic@xxxxxxxxxxxxxx> wrote:

(snip)
Well it has been defiened as allocatable,i am now attaching my code:

program pr1
use ds
implicit none
integer :: i,j,k,c,s,n_data
real,dimension(2) :: work_s
real,dimension(8,2) :: x
real,dimension(2,8) :: work_cn

It looks suspicious, though not necessarily wrong, to see two
arrays with the subscript values swapped.

real,dimension(8) :: work_n,work1_n
real,dimension(2,2) :: vv,dvv
real,dimension(4) :: dv,pp
n_data=8
s=2
c=2
open(10,file='a.dat',status='old')
open(11,file='b.dat',status='old')

do k=1,n_data
read(10,*)(x(k,s),s=1,2)
end do

It would have been useful to also supply the input data for these...

read(11,*)(pp(j),j=1,4)

vv = reshape(pp, (/ c, s /))

Nothing against RESHAPE, but it isn't hard to read in the values
in the right order:

read(11,*) ((vv(j,i),j=1,c),i=1,s)

Note that without the ORDER option, RESHAPE keeps the origina order,
which is the same as that in the data. Possibly not the order
that you expect.

do i = 1, c
do k = 1, n_data
work_s = vv(i,:) - x(k,:)
work_cn(i,k) = 1.0/dot_product(work_s, work_s)
end do
end do
do k=1,n_data
work_n(k) = double_sum(work_cn(:,k))
end do
do i = 1, c
work1_n = (work_cn(i,:)/work_n)**2
do k=1,s
dvv(i,k) = double_sum(work1_n*(vv(i,k)-x(:,k)))*2.0

Scalar (vv(i,k)) time array slice (x(:,k)) has the dimension of the
slice, so (2).

work1_n has dimension (8), multiplied by (2) doesn't look good.

end do
end do
dv = reshape(dvv, (/ c*s /))
write(*,*)dv

write(*,*) ((dvv(j,i),j=1,c),i=1,s)

end program
I get this:
forrtl: severe (408): fort: (2): Subscript #2 of the array VV has
value 3 which is greater than the upper bound of 2

It does look like all the second subscript of vv should only have
the value up to 2. The mixed dimension multiply could do it, though.

Also, if I remember it, double_sum() uses assumed shape, and I don't see
it in a module, or otherwise with an explicit interface so that it gets
called appropriately. That can easily cause variables to have unexpected
values, such that this could happen.

-- glen
.



Relevant Pages

  • Re: how to compute distance metrics with multi dimensional data
    ... Lou Pecora wrote: ... > It generalizes to any dimension. ... formula for multi dimentional time series, ... ie 2d input data or i should've called it multivariate input data ...
    (sci.nonlinear)
  • Limit of a matrix, array set, data set
    ... I try to use "reshape" function and figure out that: ... the memory] ... what is the proper way of testing the limit of the ... dimension of a matrix on a computer? ...
    (comp.soft-sys.matlab)
  • Re: Computerised authorship attribution
    ... > would be a dimension of the vector. ... Then take a look at the description of SVM at http://www.dtreg.com/svm.htm ... TreeBoost and Decision Tree Forest models for you, and you can see how well ... input data with hundreds of dimensions. ...
    (sci.stat.math)
  • Get Value from dimension.
    ... I'm trying to get the last input data in a dimension to use it in a ... calculated member, but i don't know how can i get the data it's just a ... I don't want to do a sum of values i really need only the las member of ...
    (microsoft.public.sqlserver.olap)
  • Re: How to handle matrix resizing?
    ... Since input data is generated by another program and the dimension ... unknown, normally I define A as large as possible, say ... A, to accomodate them. ...
    (comp.soft-sys.matlab)