CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Laurent_R] A file parsing and 2D array/matrix problem.: Edit Log



rushadrena
Novice

Aug 27, 2012, 2:14 AM


Views: 8588
Re: [Laurent_R] A file parsing and 2D array/matrix problem.

Laurent and Chris , Thanks a ton for sharing practical views and extensively exploring other realms of the problem space.
Yes the supermatrix will be very very sparse. But let me add the last element to the problem posed here by me.
I need to create 10 such supermatrices and concatenate them taking two at a time. For instance till now I'm able to create a text file for each of these 10 supermatrices.
Now there's the last piece of puzzle. I have created 10 such matrices (with obviously same number of rows and column).
Now the problem is that I have to concatenate (OR logic operation) two such matrices,
INPUT = Two matrices A,B (each saved in separate text files) of same row and column
OUTPUT = A single matrix C ( C[j] = A[j] OR B[j] )

Code
==============INPUT======= 
MAT - A
1875 2809 3182 3419
2809 - 1 1 -
3182 1 - - -
3186 1 1 - -
3485 - - - -
3486 - - - -

MAT - B
1875 2809 3182 3419
2809 1 - - 1
3182 - - - -
3186 - 1 1 -
3485 - - - -
3486 - 1 - 1


========== OUTPUT===========
MAT - C
1875 2809 3182 3419
2809 1 1 1 1
3182 1 - - -
3186 1 1 1 -
3485 - - - -
3486 - 1 - 1


I.e. an element of matrix will be one if either of the corresponding element of A or B is one.


(This post was edited by rushadrena on Aug 27, 2012, 2:20 AM)


Edit Log:
Post edited by rushadrena (Novice) on Aug 27, 2012, 2:20 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives