@@ -473,12 +473,14 @@ sub transpose {
473
473
474
474
#
475
475
# Get an identity matrix of the requested size
476
+ # Value::Matrix->I(n)
477
+ # $A->I # n is the number of rows of $A
476
478
#
477
479
sub I {
478
480
my $self = shift ;
479
481
my $d = shift ;
480
482
my $context = shift || $self -> context;
481
- $d = ($self -> dimensions)[0] if !defined $d && ref ($self ) && $self -> isSquare ;
483
+ $d = ($self -> dimensions)[0] if !defined $d && ref ($self );
482
484
Value::Error(" You must provide a dimension for the Identity matrix" ) unless defined $d ;
483
485
Value::Error(" Dimension must be a positive integer" ) unless $d =~ m / ^[1-9] \d *$ / ;
484
486
my @M = ();
@@ -492,13 +494,20 @@ sub I {
492
494
493
495
#
494
496
# Get an elementary matrix of the requested size and type
495
- # E(n,[i,j]) nxn, swap rows i and j
496
- # E(n,[i,j],k) nxn, replace row i with row i added to k times row j
497
- # E(n,[i],k) nxn, scale row i by k
497
+ # Value::Matrix->E(n,[i,j]) nxn, swap rows i and j
498
+ # Value::Matrix->E(n,[i,j],k) nxn, replace row i with row i added to k times row j
499
+ # Value::Matrix->E(n,[i],k) nxn, scale row i by k
500
+ # $A->E([i,j]) # n is the number of rows of $A
501
+ # $A->E([i,j],k) # n is the number of rows of $A
502
+ # $A->E([i],k) # n is the number of rows of $A
498
503
#
499
504
sub E {
500
505
my ($self , $d , $rows , $k , $context ) = @_ ;
501
- $context = $self -> context unless $context ;
506
+ if (ref $d eq ' ARRAY' ) {
507
+ ($rows , $k , $context ) = ($d , $rows , $k );
508
+ $d = ($self -> dimensions)[0] if ref ($self );
509
+ }
510
+ $context = $self -> context unless $context ;
502
511
Value::Error(" You must provide a dimension for an Elementary matrix" ) unless defined $d ;
503
512
Value::Error(" Dimension must be a positive integer" ) unless $d =~ m / ^[1-9] \d *$ / ;
504
513
my @ij = @{$rows };
@@ -534,9 +543,15 @@ sub E {
534
543
# Get a permutation matrix of the requested size
535
544
# E.g. P(3,[1,2,3]) corresponds to cycle (123) applied to rows of I_3i,
536
545
# and P(6,[1,4],[2,4,6]) corresponds to cycle product (14)(246) applied to rows of I_6
546
+ # Value::Matrix->P(n,(cycles))
547
+ # $A->P((cycles)) # n is the number of rows of $A
537
548
#
538
549
sub P {
539
550
my ($self , $d , @cycles ) = @_ ;
551
+ if (ref $d eq ' ARRAY' ) {
552
+ unshift (@cycles , $d );
553
+ $d = ($self -> dimensions)[0] if ref ($self );
554
+ }
540
555
my $context = $self -> context;
541
556
$d = ($self -> dimensions)[0] if !defined $d && ref ($self ) && $self -> isSquare;
542
557
Value::Error(" You must provide a dimension for a Permutation matrix" ) unless defined $d ;
@@ -571,6 +586,9 @@ sub P {
571
586
572
587
#
573
588
# Get an all zero matrix of the requested size
589
+ # Value::Matrix->Zero(m,n)
590
+ # Value::Matrix->Zero(n)
591
+ # $A->Zero # n is the number of rows of $A
574
592
#
575
593
sub Zero {
576
594
my ($self , $m , $n , $context ) = @_ ;
0 commit comments