Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Buenas, I'm trying to find the eigenvalues and eigenvectors of a matrix H using the Householder Method. Math::MatrixReal has many functions for this , one of them is sym_diagonalize(). The problem is that I use PDL to define H and when I run the program I get this error " Can't locate object method "sym_diagonalize" via package "PDL" ". Can't I use both modules in the same code or there is a mistake on how Im calling the functions?

use warnings; use strict; use PDL; use Math::MatrixReal; #Parámetros my $epsilon=4.52; my $d0=0.0030; my $Vprim=5; my $Dprim=4; #D/d0 #operadores P y X (NxN=15) my $P=(pdl[[ 0, -sqrt(1),0,0,0,0,0,0,0,0,0,0,0,0,0], [sqrt(1),0, -sqrt(2),0,0,0,0,0,0,0,0,0,0,0,0], [0, sqrt(2),0,-sqrt(3),0,0,0,0,0,0,0,0,0,0,0], [0,0,sqrt(3),0,-sqrt(4),0,0,0,0,0,0,0,0,0,0], [0,0,0,sqrt(4),0,-sqrt(5),0,0,0,0,0,0,0,0,0], [0,0,0,0,sqrt(5),0,-sqrt(6),0,0,0,0,0,0,0,0], [0,0,0,0,0,sqrt(6),0,-sqrt(7),0,0,0,0,0,0,0], [0,0,0,0,0,0,sqrt(7),0,-sqrt(8),0,0,0,0,0,0], [0,0,0,0,0,0,0,sqrt(8),0,-sqrt(9),0,0,0,0,0], [0,0,0,0,0,0,0,0,sqrt(9),0,-sqrt(10),0,0,0,0], [0,0,0,0,0,0,0,0,0,sqrt(10),0,-sqrt(11),0,0,0], [0,0,0,0,0,0,0,0,0,0,sqrt(11),0,-sqrt(12),0,0], [0,0,0,0,0,0,0,0,0,0,0,sqrt(12),0,-sqrt(13),0], [0,0,0,0,0,0,0,0,0,0,0,0,sqrt(13),0,-sqrt(14)], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,sqrt(14)] ]); my $X=(pdl[[0,sqrt(1),0,0,0,0,0,0,0,0,0,0,0,0,0], [sqrt(1),0, sqrt(2),0,0,0,0,0,0,0,0,0,0,0,0], [0, sqrt(2),0,sqrt(3),0,0,0,0,0,0,0,0,0,0,0], [0,0,sqrt(3),0,sqrt(4),0,0,0,0,0,0,0,0,0,0], [0,0,0,sqrt(4),0,sqrt(5),0,0,0,0,0,0,0,0,0], [0,0,0,0,sqrt(5),0,sqrt(6),0,0,0,0,0,0,0,0], [0,0,0,0,0,sqrt(6),0,sqrt(7),0,0,0,0,0,0,0], [0,0,0,0,0,0,sqrt(7),0,sqrt(8),0,0,0,0,0,0], [0,0,0,0,0,0,0,sqrt(8),0,sqrt(9),0,0,0,0,0], [0,0,0,0,0,0,0,0,sqrt(9),0,sqrt(10),0,0,0,0], [0,0,0,0,0,0,0,0,0,sqrt(10),0,sqrt(11),0,0,0], [0,0,0,0,0,0,0,0,0,0,sqrt(11),0,sqrt(12),0,0], [0,0,0,0,0,0,0,0,0,0,0,sqrt(12),0,sqrt(13),0], [0,0,0,0,0,0,0,0,0,0,0,0,sqrt(13),0,sqrt(14)], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,sqrt(14)] ]); # #trucamiento de H my $j=<STDIN>; #cambio la dimensión #parte 1 , selecciono corto columnas my $x1=slice($X,"0:$j:1"); my $p1=slice($P,"0:$j:1"); #parte 2 , selecciono corto filas my $k=0; my @index; while($k<$j+1){ push @index,$k; $k=$k+1; }; #operadores de dimensión $jx$j my $p2=$p1->dice_axis(1,[@index]); my $x2=$x1->dice_axis(1,[@index]); #verificando #print "$p2\n$x2\n"; my $a=$x2 x $x2; my $b= $x2 x $x2 x $x2 x $x2; my $c= $p2 x $p2; #print "$a\n$b\n$c\n"; my $H= -(($c)/4) + 4*($Vprim/($Dprim**4))*($b) - 4*($Vprim/($Dprim**2) +)*($a); my $l; my $v; ($l, $v) = $H->sym_diagonalize();

In reply to PDL & Math::MatrixReal by Lucero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-16 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found