Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?

by space_monk (Chaplain)
on Nov 08, 2012 at 05:30 UTC ( #1002816=note: print w/ replies, xml ) Need Help??


in reply to Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?

One of the things to learn about any programming language is that your problem has almost certainly been addressed in some way before, and in this case there are PERL CPAN libraries like Math::Matrix and Math::MatrixReal to avoid having to do any work. Using CPAN libraries also makes your code more maintainable as other people will have more chance of having come across the library concerned on CPAN than of understanding your custom code.

In answer to the input question, (and modifying an earlier answer) why not get your input as

while (<>) do { push @m2, [ split /,/, $_ ]; }
and then your script can get your input from any file or stdin....
e.g.
./myprogram.pl < d1.txt


Comment on Re: Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?
Select or Download Code
Re^2: Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?
by supriyoch_2008 (Scribe) on Nov 09, 2012 at 04:36 UTC

    Hi, space_monk

    Thank you very much for providing valuable suggestions, particularly about CPAN. The idea did not come to my mind before posting the question in Seekers of Perl Wisdom. I shall try to use Math::Matrix perl module.

    With regards

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002816]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2014-12-19 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (91 votes), past polls