So I'm using a module that requires an lower diagonal matrix. However, there seems to be some importance on how the matrix is defined.
If I were to define the matrix like this
$distmatrix=[[] , [0.25], [0.25,0.5], [1,0.75,0.75]]
Everything works fine, however, when I define a matrix like this
$main::hd=[[]];
$main::a = [0.25];
$main::b = [0.25,0.5];
$main::c = [1,0.75,0.75];
push @{main::hd}, [@main::a];
push @{main::hd}, [@main::b];
push @{main::hd}, [@main::c];
then I have an error.
Whats the difference between the two? I need to add to my distance matrix every time step as it grows, so defining the distance matrix explicitly doensn't look like an option.
EDIT
I'm still at school, but I'll try your suggestions when I get home. The code I'm using does have strict on, but the error is with two modules that I'm using, or rather, the input I'm giving the module isn't what it expects (evidenced by a croak statement)
When I run the following code
#!/usr/bin/perl
#ex2
use warnings;
use strict;
sub clust;
$main::hd=[[]];
$main::a = [0.25];
$main::b = [0.25,0.5];
$main::c = [1,0.75,0.75];
push @{main::hd}, [@main::a];
push @{main::hd}, [@main::b];
push @{main::hd}, [@main::c];
$main::hdt = 0.4;
&clust;
for ($loop::i=0; $loop::i<=3; $loop::i++)
{
print $clust::cluster_ids->[$loop::i], "\n";
}
sub clust {
use Algorithm::Cluster::Thresh;
use Algorithm::Cluster qw/treecluster/;
$clust::tree = treecluster(data=>$main::hd, method=>'a');
$clust::cluster_ids = $clust::tree->cutthresh($main::hdt);
}
I get the error "memory allocation failure in treecluster"
Which, after I read the module code comes from a croak statement if "!distmatrix" which I'm guessing means that if I input something that's not the correct kind of matrix, then it can't work.
However, If I use the code
#!/usr/bin/perl
#ex2
use warnings;
use strict;
sub clust;
$main::hd=[[] , [0.25], [0.25,0.5], [1,0.75,0.75]];
$main::hdt = 0.4;
&clust;
for ($loop::i=0; $loop::i<=3; $loop::i++)
{
print $clust::cluster_ids->[$loop::i], "\n";
}
sub clust {
use Algorithm::Cluster::Thresh;
use Algorithm::Cluster qw/treecluster/;
$clust::tree = treecluster(data=>$main::hd, method=>'a');
$clust::cluster_ids = $clust::tree->cutthresh($main::hdt);
}
I get the desired output
1
1
1
0
Sorry for being so vague, and I'll try your solutions tonight when I get home.