-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
84 lines (57 loc) · 2.39 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Math::Symbolic::Custom::Matrix
==============================
Matrix routines for Math::Symbolic.
Provides some routines for manipulating matrices of Math::Symbolic expressions. A matrix here is just a 2D array of
elements. Passing in matrices with elements which are not already Math::Symbolic objects will cause them to be
converted to Math::Symbolic objects.
EXAMPLE
use strict;
use Math::Symbolic qw/:all/;
use Math::Symbolic::MiscAlgebra qw/:all/;
use Math::Symbolic::Custom::Collect 0.21;
use Math::Symbolic::Custom::Matrix;
use Math::Symbolic::Custom::Polynomial;
# Say we want the eigenvalues of some matrix with a parameter.
# 1. A = | 4, 3-k |
# | 2, 3 |
my @matrix = ([4,'3-k'],[2,3]);
my $A = make_symbolic_matrix(\@matrix);
# 2. get an identity matrix
my $I = identity_matrix(2);
# 3. multiply it with lambda
my $lambda_I = scalar_multiply_matrix( "lambda", $I );
# 4. subtract it from matrix A
my $B = sub_matrix($A, $lambda_I);
# 5. form the characteristic polynomial, |A-lambda*I|
my $c_poly = det(@{$B})->to_collected();
print "Characteristic polynomial is: $c_poly\n";
# 6. analyze the polynomial to get roots
my ($var, $coeffs, $disc, $roots) = $c_poly->test_polynomial('lambda');
print "Expressions for the roots are:\n\t$roots->[0]\n\t$roots->[1]\n";
# 7. Check for some values of parameter k
foreach my $k (0..3) {
print "For k = $k:- lambda_1 = ",
$roots->[0]->value('k' => $k), "; lambda_2 = ",
$roots->[1]->value('k' => $k), "\n";
}
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the
perldoc command.
perldoc Math::Symbolic::Custom::Matrix
You can also look for information at:
RT, CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Math-Symbolic-Custom-Matrix
CPAN Ratings
https://cpanratings.perl.org/d/Math-Symbolic-Custom-Matrix
Search CPAN
https://metacpan.org/release/Math-Symbolic-Custom-Matrix
LICENSE AND COPYRIGHT
This software is copyright (c) 2024 by Matt Johnson.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.