| | |
How to make matrix?
![]() |
•
•
Join Date: Jan 2007
Posts: 1
Reputation:
Solved Threads: 0
I am total novice, but I must solve this problem very quick and need help. Problem:I’ve been given a file
1 2 15
1 3 16
2 3 20
and so on…First two values of the input file represents graph nodes and the third one is distance between them. I know the number of nodes(in previous example number of nodes is 4, counting starts from 0)
I need perl code that makes a matrix that looks like this:
0 0 0 0
0 0 15 16
0 15 0 20
0 16 20 0
Thanks in advance!!!
1 2 15
1 3 16
2 3 20
and so on…First two values of the input file represents graph nodes and the third one is distance between them. I know the number of nodes(in previous example number of nodes is 4, counting starts from 0)
I need perl code that makes a matrix that looks like this:
0 0 0 0
0 0 15 16
0 15 0 20
0 16 20 0
Thanks in advance!!!
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
You can do many things, the easiest of which to describe would be to use an array and fill it with nested for loops. As long as you have the same number of data in each row, accessing the data is a simple matter of dividing your array into n parts.
2x4 matrix:
[][][][]
()()()()
array structure:
[][][][]()()()()
2x4 matrix:
[][][][]
()()()()
array structure:
[][][][]()()()()
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
![]() |
Similar Threads
- Signal Processing: Hadamard Matrices (C)
- adding matrices in c++ (C++)
- i need help with like a Visio but not (Windows Software)
- creating our own C++ strcat() function, code reqd (C++)
- Dynamic Array, Writing to CSV, Floating Point ?'s (C)
- The Matrix & Philosophy (Geeks' Lounge)
- making a matrix (C)
Other Threads in the Perl Forum
- Previous Thread: Execute unix command from perl running on windows
- Next Thread: Strange issue with arrays
| Thread Tools | Search this Thread |





