use PDL; use PDL::Matrix; $file1 = $ARGV[0]; $file2 = $ARGV[1]; open(DATA1, "$file1") || die "Error: Unable to open $file1:$!\n"; open(DATA2, "$file2") || die "Error: Unable to open $file2:$!\n"; my $fileone; my $filetwo; while ( ) { chomp; #my @l = split /,\s+/; my @line1 = split(/,/); # for loop for($i = 0; $i < 35; $i++) { push @{$fileone->[$i]}, $line1[$i]; } } $fileone = PDL::Matrix->pdl($fileone); while ( ) { chomp; my @line2 = split (/,/); for($j = 0; $j < 35; $j++) { push @{$filetwo->[$j]}, $line2[$j]; } } $filetwo = PDL::Matrix->pdl($filetwo); $m = $fileone->transpose(); ($V, $S, $U) = svd($m); @valuesS = list $S; $SqS = stretcher($S); $Vs = $V->slice('0:7,0:34'); $Ut = $U->transpose(); $Ss = $SqS->slice('0:7,0:7'); $Us = $Ut->slice('0:70,0:7'); $A = $Us x $Ss x $Vs; ($Uf, $Sf, $Vf) = svd($sec); $B = $Vf->transpose(); @valuesSf = list $Sf; $SqSf = stretcher($Sf); $shortS = $SqSf->slice('0:6,0:6'); $invSf = $shortS->inv(); my $zeros = zeroes(28,7); $invSftransposed=transpose($invSf); $C = $invSftransposed->append($zeros); $C=transpose($C); $D = $Uf->slice('0:6,0:6'); # PDL coughs at the next command. $x = A x B x C x D;