- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have 3 by 3 arrary(xpy).
I want to select (2,1), (3,2) element from the arrary.
I know the position of row and columnas followingrw = (/2, 3/) and cl = (/1,2/).
So I want to select cross point of rw and cl arrays.
How can I select?
I want to select (2,1), (3,2) element from the arrary.
I know the position of row and columnas followingrw = (/2, 3/) and cl = (/1,2/).
So I want to select cross point of rw and cl arrays.
How can I select?
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean following?
Do i=1, 2
xpy(rw(i), cl(i)) = ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, I want to store the result of matrix multiplication into the specific elements of 2 dim array.
for example
I have the result of 2 by 2 matrix and 2 by 1 vector multiplication and want to store it into (2,1) (3,2) of 3 by 3 matrix at one time.
Is it possible?
for example
I have the result of 2 by 2 matrix and 2 by 1 vector multiplication and want to store it into (2,1) (3,2) of 3 by 3 matrix at one time.
Is it possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - bhpark70rda.go.kr
Actually, I want to store the result of matrix multiplication into the specific elements of 2 dim array.
for example
I have the result of 2 by 2 matrix and 2 by 1 vector multiplication and want to store it into (2,1) (3,2) of 3 by 3 matrix at one time.
Is it possible?
for example
I have the result of 2 by 2 matrix and 2 by 1 vector multiplication and want to store it into (2,1) (3,2) of 3 by 3 matrix at one time.
Is it possible?
No, it's not possible in the single line.
For 1-D case, you may use an index (order) array, for example:
real:: A(5) = (/1., 2., 3., 4., 5.,/)
integer:: iOrder(2) = (/2, 5/)
A(iOrder) = 0. !gives 1, 0, 3, 4, 0
But there's no equivalent construct for 2-D case -- you may not use a 2-d array as an index array. You have to use a DO-loop, as Yolanda outlined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jugoslav Dujic
You have to use a DO-loop, as Yolanda outlined.
Or, for extra obfuscation points and a possible saving of two keystrokes ;)
FORALL (i=1:2) xpy(rw(i),cl(i)) = the_source(i)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jugoslav Dujic
But there's no equivalent construct for 2-D case -- you may not use a 2-d array as an index array. You have to use a DO-loop, as Yolanda outlined.
Fortran 90/95 (2003 has more extensions)do providea special intrinsic function, callled RESHAPE, that changes the shape of an array,which can initialize a 2-D array in a single assignment, the form of the RESHAPE function is:
output = RESHAPE ( array1, array2)
where array1 contains the data to reshape and array2 is a rank-1 array describing the new shape. The number of elements in array2 is the number of dimensions in the output array, and the value of each element in array2 is the extent of each dimenstion. The number of elements in array 1 must be the same as the number of elements in the shape specified in array2, or the RESHAPE function will fail.
As for bhpark70rda.go.kr's case,we can have:
integer, dimension(3,3):: xpy
xpy = RESHAPE ( /11, *, 31, 12, 22, *, 13, 23, 33/, /3,3/)
Where *are the position of (2,1) (3,2) you put your result into.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page