Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by 2teez (Priest)
on Nov 08, 2012 at 04:56 UTC ( #1002812=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?

Hi, supriyoch_2008,

  • Please you may use strict in your script.
  • Replace these lines in inv2.pl:
    ## Input the matrix text file: print "\n\n Please type the filename(.txt) i.e. d1.txt: "; $DNAfilename = <STDIN>; chomp $DNAfilename; ## To remove white space: $DNAfilename=~ s/\s//gis; # open the file, or exit unless ( open(DNAFILE, $DNAfilename) ) { print "Cannot open file \"$DNAfilename\"\n\n"; exit; } # Line 10 @a = <DNAFILE>; @m2=@a;
    with these:
    my @m2; ## Input the matrix text file: print "\n\n Please type the filename(.txt) i.e. d1.txt: "; chomp( my $filename = <STDIN> ); open my $fh, '<', $filename or die "can't open file $!"; while (<$fh>) { push @m2, [ split /,/, $_ ]; } close $fh or die "can't close file: $!";
Note:
Ofcourse, your script(s) can be improved upon, but these should give you what you want to start with.
Hope it helps.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
  • 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

Replies are listed 'Best First'.
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 (Monk) on Nov 09, 2012 at 04:25 UTC

    Hi, 2teez,

    Thanks for your suggestions with code. I shall try.

    Regards

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002812]
help
Chatterbox?
[marto]: code you write/port that runs via the terminal?
[robby_dobby]: guess I have to take a look at it off-work. I don't understand what those words mean, honestly :-)
[Corion]: Oooh. Tinc really looks good. It seems that it could even be used to link up (a segment of) my home network with (a segment of) a friends network, to create a private network over the internet
[marto]: fun times :)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2018-01-17 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (201 votes). Check out past polls.

    Notices?