Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Math::LinearCombination 0.03

    Download button

    No screenshots available
    Downloads: 108  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Wim Verhaegen | More programs
    Perl Artistic License / FREE
    March 17th, 2011, 06:59 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Math::LinearCombination description

    Sum of variables with a numerical coefficient

    Math::LinearCombination is a Perl module for representing mathematical linear combinations of variables, i.e. expressions of the format

     a1 * x1 + a2 * x2 + ... + an * xn

    with x1, x2, ..., xn variables, and a1, a2, ..., an numerical coefficients. Evaluation and manipulation of linear combinations is also supported. The numerical coefficients a_i and variables x_i are stored as pairs in an internal data structure and should not be manipulated directly. All access and manipulation should be performed through the methods.

    SYNOPSIS

     use Math::LinearCombination;
     use Math::SimpleVariable; # for the variable objects

     # build a linear combination
     my $x1 = new Math::SimpleVariable(name => 'x1');
     my $x2 = new Math::SimpleVariable(name => 'x2');
     my $lc = new Math::LinearCombination();
     $lc->add_entry(var => $x1, coeff => 3.0);
     $lc->add_entry(var => $x2, coeff => 1.7);
     $lc->add_entry(var => $x2, coeff => 0.3); # so x2 has a coefficient of 2.0
     print $lc->stringify(), "\n";

     # do some manipulations
     $lc->negate_inplace(); # reverts the coefficient signs
     $lc->multiply_with_constant_inplace(2.0); # doubles all coefficients
     
     # evaluate the linear combination
     $x1->{value} = 3;
     $x2->{value} = -1;
     print $lc->evaluate(), "\n"; # prints -14



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    numerical coefficient | variables sum | Perl module | liniar | variables | sum

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM