403Webshell
Server IP : 173.236.223.38  /  Your IP : 216.73.216.33
Web Server : Apache
System : Linux vps62975 6.8.0-83-generic #83~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Sep 9 18:19:47 UTC 2 x86_64
User : invmicvps ( 6727287)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/perl5/PDF/API2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/perl5/PDF/API2/Matrix.pm
package PDF::API2::Matrix;

use strict;

use Carp;

our $VERSION = '2.043'; # VERSION

sub new {
    my $type = shift();
    my $self = [];
    my $col_count = scalar(@{$_[0]});
    foreach my $row (@_) {
        unless (scalar(@$row) == $col_count) {
            carp 'Inconsistent column count in matrix';
            return;
        }
        push @$self, [@$row];
    }

    return bless($self, $type);
}

sub transpose {
    my $self = shift();
    my @result;
    my $m;

    for my $col (@{$self->[0]}) {
        push @result, [];
    }
    for my $row (@$self) {
        $m = 0;
        for my $col (@$row) {
            push @{$result[$m++]}, $col;
        }
    }

    return PDF::API2::Matrix->new(@result);
}

sub vector_product {
    my ($a, $b) = @_;
    my $result = 0;

    for my $i (0 .. $#{$a}) {
        $result += $a->[$i] * $b->[$i];
    }

    return $result;
}

sub multiply {
    my $self  = shift();
    my $other = shift->transpose();
    my @result;

    unless ($#{$self->[0]} == $#{$other->[0]}) {
        carp 'Mismatched dimensions in matrix multiplication';
        return;
    }
    for my $row (@$self) {
        my $result_col = [];
        for my $col (@$other) {
            push @$result_col, vector_product($row, $col);
        }
        push @result, $result_col;
    }

    return PDF::API2::Matrix->new(@result);
}

1;

Youez - 2016 - github.com/yon3zu
LinuXploit