Skip to content

Commit

Permalink
Merge pull request #307 from dpvc/matrix-fix
Browse files Browse the repository at this point in the history
Convert vectors to column matrices for some matrix operations.
  • Loading branch information
mgage authored Jul 7, 2017
2 parents 7bddd8a + 5ac0e4f commit 8f22d5f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/Value/Matrix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ sub wwMatrixLR {
return $self->{lrM};
}

sub wwColumnVector {
my $self = shift;
my $v = shift;
my $V = $self->new($v);
$V = $V->transpose if Value::classMatch($v,'Vector');
return $V->wwMatrix;
}


###################################
#
Expand Down Expand Up @@ -458,15 +466,15 @@ sub kleene {

sub normalize {
my $self = shift;
my $v = $self->new(shift)->wwMatrix;
my $v = $self->wwColumnVector(shift);
my ($M,$b) = $self->wwMatrix->normalize($v);
return ($self->new($M),$self->new($b));
}

sub solve {shift->solve_LR(@_)}
sub solve_LR {
my $self = shift;
my $v = $self->new(shift)->wwMatrix;
my $v = $self->wwColumnVector(shift);
my ($d,$b,$M) = $self->wwMatrixLR->solve_LR($v);
return ($d,$self->new($b),$self->new($M));
}
Expand All @@ -485,8 +493,8 @@ sub order_LR {

sub solve_GSM {
my $self = shift;
my $x0 = $self->new(shift)->wwMatrix;
my $b = $self->new(shift)->wwMatrix;
my $x0 = $self->wwColumnVector(shift);
my $b = $self->wwColumnVector(shift);
my $e = shift;
my $v = $self->wwMatrix->solve_GSM($x0,$b,$e);
$v = $self->new($v) if defined($v);
Expand All @@ -495,8 +503,8 @@ sub solve_GSM {

sub solve_SSM {
my $self = shift;
my $x0 = $self->new(shift)->wwMatrix;
my $b = $self->new(shift)->wwMatrix;
my $x0 = $self->wwColumnVector(shift);
my $b = $self->wwColumnVector(shift);
my $e = shift;
my $v = $self->wwMatrix->solve_SSM($x0,$b,$e);
$v = $self->new($v) if defined($v);
Expand All @@ -505,8 +513,8 @@ sub solve_SSM {

sub solve_RM {
my $self = shift;
my $x0 = $self->new(shift)->wwMatrix;
my $b = $self->new(shift)->wwMatrix;
my $x0 = $self->wwColumnVector(shift);
my $b = $self->wwColumnVector(shift);
my $w = shift; my $e = shift;
my $v = $self->wwMatrix->solve_RM($x0,$b,$w,$e);
$v = $self->new($v) if defined($v);
Expand Down

0 comments on commit 8f22d5f

Please sign in to comment.