comparison docs/modules/txt/Matrix.txt @ 0:4816e4a8ae95 draft default tip

Uploaded
author deepakjadmin
date Wed, 20 Jan 2016 09:23:18 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4816e4a8ae95
1 NAME
2 Matrix
3
4 SYNOPSIS
5 use Matrix;
6
7 use Matrix qw(:all);
8
9 DESCRIPTION
10 Matrix class provides the following methods:
11
12 new, AddColumnValues, AddRowValues, Copy, GetColumnValues,
13 GetColumnValuesAsColumnMatrix, GetColumnValuesAsRowMatrix,
14 GetColumnValuesAsString, GetColumnValuesAsVector, GetDiagonalValues,
15 GetDiagonalValuesAsColumnMatrix, GetDiagonalValuesAsRowMatrix,
16 GetDiagonalValuesAsString, GetDiagonalValuesAsVector, GetDimension,
17 GetMatrixValuesReference, GetNumOfColumns, GetNumOfRows, GetRowValues,
18 GetRowValuesAsColumnMatrix, GetRowValuesAsRowMatrix,
19 GetRowValuesAsString, GetRowValuesAsVector, GetSize, GetValue,
20 IdentityMatrix, IsAntiSymmetric, IsBiDiagonal, IsDiagonal, IsIdentity,
21 IsLeftTriangular, IsLowerBiDiagonal, IsLowerTriangular,
22 IsLowerUniTriangular, IsMatrix, IsNegative, IsPositive,
23 IsRightTriangular, IsSkewSymmetric, IsSquare, IsStrictlyLowerTriangular,
24 IsStrictlyUpperTriangular, IsSymmetric, IsTriDiagonal, IsUnit,
25 IsUnitLowerTriangular, IsUnitUpperTriangular, IsUpperBiDiagonal,
26 IsUpperTriangular, IsUpperUniTriangular, NewFromColumns,
27 NewFromDiagonal, NewFromRows, One, SetAllValues, SetColumnValues,
28 SetDiagonalValues, SetMatrixPrintStyle, SetRowValues, SetValue,
29 SetValuePrintFormat, StringifyMatrix, Transpose, UnitMatrix, Zero,
30 ZeroMatrix
31
32 The following functions are available:
33
34 IsMatrix, IdentityMatrix, NewFromRows, NewFromColumns, NewFromDiagonal,
35 UnitMatrix, ZeroMatrix
36
37 The following operators are overloaded:
38
39 "" bool !
40 @{}
41 + - * / ** %
42 == != < <= > >=
43 neg
44 abs exp log sqrt cos sin
45
46 The matrix row and column indicies start from zero.
47
48 FUNCTIONS
49 new
50 $NewMatrix = $Matrix->new($NumOfRows, $NumOfCols);
51
52 Creates a new Matrix of size *NumOfRows x NumOfCol* and returns
53 NewMatrix object.
54
55 AddColumnValues
56 $Matrix->AddColumnValues(@Values);
57 $Matrix->AddColumnValues(\@Values);
58 $Matrix->AddColumnValues($VectorObject);
59 $Matrix->AddColumnValues("Value1 Value2 Value3 ...");
60
61 Adds column values to *Matrix* using an array, reference to an
62 array, another vector, or space delimited value string and returns
63 *Matrix*.
64
65 AddRowValues
66 $Matrix->AddRowValues(@Values);
67 $Matrix->AddRowValues(\@Values);
68 $Matrix->AddRowValues($VectorObject);
69 $Matrix->AddRowValues("Value1 Value2 Value3 ...");
70
71 Adds row values to *Matrix* using an array, reference to an array,
72 another vector, or space delimited value string and returns Matrix.
73
74 Copy
75 $NewMatrix = $Matrix->Copy();
76
77 Creates a copy of *Matrix* and returns NewMatrix.
78
79 GetColumnValues
80 @Values = $Matrix->GetColumnValues($ColIndex);
81 $ValueCount = $Matrix->GetColumnValues($ColIndex);
82
83 Returns an array containing column value specified using *ColIndex*
84 with column index starting at 0. In scalar context, number of column
85 values is returned.
86
87 GetColumnValuesAsColumnMatrix
88 $ColumnMatrix = $Matrix->GetColumnValuesAsColumnMatrix($ColIndex);
89
90 Returns a new ColumnMatrix containing column values specified using
91 *ColIndex* with column index starting at 0.
92
93 GetColumnValuesAsRowMatrix
94 $RowMatrix = $Matrix->GetColumnValuesAsRowMatrix($ColIndex);
95
96 Returns a new RowMatrix containing column values specified using
97 *ColIndex* with column index starting at 0.
98
99 GetColumnValuesAsString
100 $ColumnValuesString = $Matrix->GetColumnValuesAsString($ColIndex);
101
102 Returns a space delimited ColumnValuesString column values specified
103 using *ColIndex* with column index starting at 0.
104
105 GetColumnValuesAsVector
106 $ColumnVector = $Matrix->GetColumnValuesAsVector($ColIndex);
107
108 Returns a new ColumnVector column values specified using *RowIndex*
109 with column index starting at 0.
110
111 GetDiagonalValues
112 @Values = $Matrix->GetDiagonalValues();
113 $ValueCount = $Matrix->GetDiagonalValues();
114
115 Returns an array containing diagonal values. In scalar context,
116 number of diagonal values is returned.
117
118 GetDiagonalValuesAsColumnMatrix
119 $ColumnMatrix = $Matrix->GetDiagonalValuesAsColumnMatrix();
120
121 Returns a new ColumnMatrix containing diagonal values corresponding
122 to *Matrix*.
123
124 GetDiagonalValuesAsRowMatrix
125 $RowMatrix = $Matrix->GetDiagonalValuesAsRowMatrix();
126
127 Returns a new RowMatrix containing diagonal values corresponding to
128 *Matrix*.
129
130 GetDiagonalValuesAsString
131 $DiagonalValuesString = $Matrix->GetDiagonalValuesAsString();
132
133 Returns a space delimited DiagonalValuesString containing diagonal
134 values corresponding to *Matrix*.
135
136 GetDiagonalValuesAsVector
137 $DiagonalVector = $Matrix->GetDiagonalValuesAsVector();
138
139 Returns a new DiagonalVector containing diagonal values
140 corresponding to *Matrix*.
141
142 GetDimension
143 ($NumOfRows, $NumOfCols) = $Matrix->GetDimension();
144
145 Returns size of *Matrix*.
146
147 GetMatrixValuesReference
148 $ValuesRef = $Matrix->GetMatrixValuesReference();
149
150 Returns a reference to array containing rows and column values
151 corresponding to *Matrix*.
152
153 GetNumOfColumns
154 $NumOfCols = $Matrix->GetNumOfColumns();
155
156 Returns NumOfCols in *Matrix*.
157
158 GetNumOfRows
159 $NumOfRows = $Matrix->GetNumOfRows();
160
161 Returns NumOfRows in *Matrix*.
162
163 GetRowValues
164 @Values = $Matrix->GetRowValues($RowIndex);
165 $ValueCount = $Matrix->GetRowValues($RowIndex);
166
167 Returns an array containing row value specified using *RowIndex*
168 with row index starting at 0. In scalar context, number of row
169 values is returned.
170
171 GetRowValuesAsColumnMatrix
172 $ColumnMatrix = $Matrix->GetRowValuesAsColumnMatrix($RowIndex);
173
174 Returns a new ColumnMatrix containing row values specified using
175 *RowIndex* with column index starting at 0.
176
177 GetRowValuesAsRowMatrix
178 $RowMatrix = $Matrix->GetRowValuesAsRowMatrix($RowIndex);
179
180 Returns a new RowMatrix containing row values specified using
181 *RowIndex* with row index starting at 0.
182
183 GetRowValuesAsString
184 $RowValuesString = $Matrix->GetRowValuesAsString($RowIndex);
185
186 Returns a space delimited RowValuesString row values specified using
187 *RowIndex* with row index starting at 0.
188
189 GetRowValuesAsVector
190 $RowVector = $Matrix->GetColumnValuesAsVector($RowIndex);
191
192 Returns a new RowVector row values specified using *RowIndex* with
193 row index starting at 0.
194
195 GetSize
196 ($NumOfRows, $NumOfCols) = $Matrix->GetSize();
197
198 Returns size of *Matrix*.
199
200 GetValue
201 $Value = $Matrix->GetValue($RowIndex, $ColIndex, [$SkipIndexCheck]);
202
203 Returns Value of *Matrix* element specified using *RowIndex* and
204 *ColIndex* with indicies starting at 0 with optional validation of
205 specified index values.
206
207 IdentityMatrix
208 $NewIdentityMatrix = $Matrix->IdentityMatrix($NumOfRows, $NumOfCols);
209 $NewIdentityMatrix = Matrix::IdentityMatrix($NumOfRows, $NumOfCols);
210 $NewIdentityMatrix = Matrix::IdentityMatrix();
211
212 Creates a new IdentityMatrix of specified size *NumOfRows x
213 NumOfCol* or of size 3 x 3 and returns NewIdentityMatrix object.
214
215 IsAntiSymmetric
216 $Status = $Matrix->IsAntiSymmetric();
217
218 Returns 1 or 0 based on whether *Matrix* is an anti symmetric
219 matrix.
220
221 A matrix is an anti symmetric matrix:
222
223 . It's a square matrix
224 . Its elements are asymmetric with respect to main diagonal. In other words,
225 elements below the main diagonal are equal to the negative of elements above
226 the main diagonal.
227
228 Transpose of an anti symmetric matrix equals the negative of the
229 matrix.
230
231 IsBiDiagonal
232 $Status = $Matrix->IsBiDiagonal();
233
234 Returns 1 or 0 based on whether *Matrix* is upper or lower
235 bidiagonal matrix.
236
237 IsDiagonal
238 $Status = $Matrix->IsDiagonal();
239
240 Returns 1 or 0 based on whether *Matrix* is a diagonal matrix.
241
242 A matrix is a diagonal matrix:
243
244 . It's a square matrix
245 . All its off-diagonal elements are zeros and its diagonal elements may or may not
246 be zeros
247
248 IsIdentity
249 $Status = $Matrix->IsIdentity();
250
251 Returns 1 or 0 based on whether *Matrix* is an identity matrix.
252
253 IsLeftTriangular
254 $Status = $Matrix->IsLeftTriangular();
255
256 Returns 1 or 0 based on whether *Matrix* is a left or lower matrix.
257
258 A matrix is a left triangular matrix:
259
260 . It's a square matrix
261 . All its entries above the main diagonal are zero
262
263 IsLowerBiDiagonal
264 $Status = $Matrix->IsLowerBiDiagonal();
265
266 Returns 1 or 0 based on whether *Matrix* is a lower bidiagonal
267 matrix.
268
269 A matrix is a lower bidiagonal matrix:
270
271 . It's a square matrix
272 . All its main diagonal and lower diagonal elements are non-zeros and all its
273 other elements are zeros
274
275 IsLowerTriangular
276 $Status = $Matrix->IsLowerTriangular();
277
278 Returns 1 or 0 based on whether *Matrix* is a left or lower
279 triangular matrix.
280
281 A matrix is a lower triangular matrix:
282
283 . It's a square matrix
284 . All its entries above the main diagonal are zero
285
286 IsLowerUniTriangular
287 $Status = $Matrix->IsLowerUniTriangular();
288
289 Returns 1 or 0 based on whether *Matrix* is a lower triangular
290 matrix.
291
292 IsMatrix
293 $Status = Matrix::IsMatrix($Object);
294
295 Returns 1 or 0 based on whether *Object* is a Matrix object.
296
297 IsNegative
298 $Status = $Matrix->IsNegative();
299
300 Returns 1 or 0 based on whether *Matrix* is a negative matrix
301 containing only values less than or equal to zero.
302
303 IsPositive
304 $Status = $Matrix->IsPositive();
305
306 Returns 1 or 0 based on whether *Matrix* is a negative matrix
307 containing only values greater than or equal to zero.
308
309 IsRightTriangular
310 $Status = $Matrix->IsRightTriangular();
311
312 Returns 1 or 0 based on whether *Matrix* is a right or upper
313 triangular matrix.
314
315 IsSkewSymmetric
316 $Status = $Matrix->IsSkewSymmetric();
317
318 Returns 1 or 0 based on whether *Matrix* is a skew or anti symmetric
319 matrix.
320
321 IsSquare
322 $Status = $Matrix->IsSquare();
323
324 Returns 1 or 0 based on whether *Matrix* is a square matrix
325 containing equal number of rows and columns.
326
327 IsStrictlyLowerTriangular
328 $Status = $Matrix->IsStrictlyLowerTriangular();
329
330 Returns 1 or 0 based on whether *Matrix* is a strictly lower
331 triangular matrix.
332
333 A matrix is a strictly lower triangular matrix:
334
335 . It's a square matrix
336 . All its entries on and above the main diagonal are zero
337
338 IsStrictlyUpperTriangular
339 $Status = $Matrix->IsStrictlyUpperTriangular();
340
341 Returns 1 or 0 based on whether *Matrix* is a strictly upper
342 triangular matrix.
343
344 A matrix is a strictly upper triangular matrix:
345
346 . It's a square matrix
347 . All its entries on and below the main diagonal are zero
348
349 IsSymmetric
350 $Status = $Matrix->IsSymmetric();
351
352 Returns 1 or 0 based on whether *Matrix* is a symmetric matrix.
353
354 A matrix is a symmetric matrix:
355
356 . It's a square matrix
357 . Its elements are symmetric with respect to main diagonal. In other words,
358 elements below the main diagonal are equal to the elements above the main
359 diagonal.
360
361 Transpose of a symmetric matrix equals the matrix itself.
362
363 IsTriDiagonal
364 $Status = $Matrix->IsTriDiagonal();
365
366 Returns 1 or 0 based on whether *Matrix* is a tridiagonal matrix.
367
368 A matrix is a tribidiagonal matrix:
369
370 . It's a square matrix
371 . All its main diagonal, upper diagonal, and lower diagonal elements are non-zeros and all its
372 other elements are zeros
373
374 IsUnit
375 $Status = $Matrix->IsUnit();
376
377 Returns 1 or 0 based on whether *Matrix* is a unit matrix.
378
379 A matrix is a unit matrix:
380
381 . It's a square matrix
382 . All its diagonal elements are ones and its off-diagonal elements are zeros
383
384 IsUnitLowerTriangular
385 $Status = $Matrix->IsUnitLowerTriangular();
386
387 Returns 1 or 0 based on whether *Matrix* is an unit lower triangular
388 matrix.
389
390 A matrix is an unit lower triangular matrix:
391
392 . It's a square matrix
393 . All its entries main diagonal are one
394 . All its entries above the main diagonal are zero
395
396 IsUnitUpperTriangular
397 $Status = $Matrix->IsUnitUpperTriangular();
398
399 Returns 1 or 0 based on whether *Matrix* is an unit upper triangular
400 matrix.
401
402 A matrix is an unit upper triangular matrix:
403
404 . It's a square matrix
405 . All its entries main diagonal are one
406 . All its entries below the main diagonal are zero
407
408 IsUpperBiDiagonal
409 $Status = $Matrix->IsUpperBiDiagonal();
410
411 Returns 1 or 0 based on whether *Matrix* is an upper bidiagonal
412 matrix.
413
414 A matrix is an upper bidiagonal matrix:
415
416 . It's a square matrix
417 . All its main diagonal and upper diagonal elements are non-zeros and all its
418 other elements are zeros
419
420 IsUpperTriangular
421 $Status = $Matrix->IsUpperTriangular();
422
423 Returns 1 or 0 based on whether *Matrix* is a right or upper
424 triangular matrix.
425
426 A matrix is an upper triangular matrix:
427
428 . It's a square matrix
429 . All its entries below the main diagonal are zero
430
431 IsUpperUniTriangular
432 $Status = $Matrix->IsUpperUniTriangular();
433
434 Returns 1 or 0 based on whether *Matrix* is a right or upper
435 triangular matrix.
436
437 NewFromColumns
438 $NewMatrix = Matrix::NewFromColumns($Col1Vector, $Col2Vector, ...);
439 $NewMatrix = Matrix::NewFromColumns($Col1ValuesRef, $Col2ValuesRef, ...);
440 $NewMatrix = Matrix::NewFromColumns("Val1 Val2 ...", "Val1 Val2", ...);
441
442 $NewMatrix = $Matrix->NewFromColumns($Col1Vector, $Col2Vector, ...);
443 $NewMatrix = $Matrix->NewFromColumns($Col1ValuesRef, $Col2ValuesRef, ...);
444 $NewMatrix = $Matrix->NewFromColumns("Val1 Val2 ...", "Val1 Val2", ...);
445
446 Creates a new Matrix using specified column values and returns
447 NewMatrix object.
448
449 The column values can be specified in one of the following formats:
450
451 . List of vector objects
452 . References to list of values
453 . List of strings containing columns values delimited by space
454
455 Each column must contain the same number of values.
456
457 NewFromDiagonal
458 $NewMatrix = Matrix::NewFromDiagonal($DiagonalVector);
459 $NewMatrix = Matrix::NewFromDiagonal($DiagonalValuesRef);
460 $NewMatrix = Matrix::NewFromDiagonal("Val1 Val2 ...");
461
462 $NewMatrix = Matrix->NewFromDiagonal($DiagonalVector);
463 $NewMatrix = Matrix->NewFromDiagonal($DiagonalValuesRef);
464 $NewMatrix = Matrix->NewFromDiagonal("Val1 Val2 ...");
465
466 Creates a new Matrix using specified diagonal values and returns
467 NewMatrix object.
468
469 The column values can be specified in one of the following formats:
470
471 . A vector object
472 . Reference to list of values
473 . Strings containing diagonal values delimited by space
474
475 NewFromRows
476 $NewMatrix = Matrix::NewFromRows($Row1Vector, $RowVector, ...);
477 $NewMatrix = Matrix::NewFromRows($Row1ValuesRef, $Row2ValuesRef, ...);
478 $NewMatrix = Matrix::NewFromRows("Val1 Val2 ...", "Val1 Val2", ...);
479
480 $NewMatrix = $Matrix->NewFromRows($Row1Vector, $Row2Vector, ...);
481 $NewMatrix = $Matrix->NewFromRows($Row1ValuesRef, $Row2ValuesRef, ...);
482 $NewMatrix = $Matrix->NewFromRows("Val1 Val2 ...", "Val1 Val2", ...);
483
484 Creates a new Matrix using specified row values and returns
485 NewMatrix object.
486
487 The row values can be specified in one of the following formats:
488
489 . List of vector objects
490 . References to list of values
491 . List of strings containing columns values delimited by space
492
493 Each row must contain the same number of values.
494
495 One
496 $Matrix->One();
497
498 Sets values of all *Matrix* elements to 1 and returns *Matrix*.
499
500 SetAllValues
501 $Matrix->SetAllValues($Value);
502
503 Sets values of all *Matrix* elements to specified *Value* and
504 returns *Matrix*.
505
506 SetColumnValues
507 $Matrix->SetColumnValues($ColIndex, @Values);
508 $Matrix->SetColumnValues($ColIndex, \@Values);
509 $Matrix->SetColumnValues($ColIndex, $VectorObject);
510 $Matrix->SetColumnValues($ColIndex, "Value1 Value2 Value3 ...");
511
512 Sets column values of a specified *ColIndex* of *Matrix* using an
513 array, reference to an array, another vector, or space delimited
514 value string and returns *Matrix*.
515
516 SetDiagonalValues
517 $Matrix->SetDiagonalValues(@Values);
518 $Matrix->SetDiagonalValues(\@Values);
519 $Matrix->SetDiagonalValues($VectorObject);
520 $Matrix->SetDiagonalValues("Value1 Value2 Value3 ...");
521
522 Sets values of the diagonal in square *Matrix* and returns *Matrix*.
523
524 SetMatrixPrintStyle
525 $Matrix->SetMatrixPrintStyle($MatrixStyle);
526 $Matrix::SetMatrixPrintStyle($MatrixStyle);
527
528 Sets print style for matrix rows for an individual object or the
529 whole class during StringifyMatrix operation. Possible *MatrixStyle*
530 values: *AllRowsInOneLine, OneRowPerLine*. Default:
531 *AllRowsInOneLine*.
532
533 SetRowValues
534 $Matrix->SetRowValues($ColIndex, @Values);
535 $Matrix->SetRowValues($ColIndex, \@Values);
536 $Matrix->SetRowValues($ColIndex, $VectorObjext);
537 $Matrix->SetRowValues($ColIndex, "Value1 Value2 Value3 ...");
538
539 Sets row values of a specified *RowIndex* of *Matrix* using an
540 array, reference to an array, another vector, or space delimited
541 value string and returns *Matrix*.
542
543 SetValue
544 $Matrix->SetValue($RowIndex, $ColIndex, $Value, [$SkipIndexCheck]);
545
546 Sets Value of *Matrix* element specified using *RowIndex* and
547 *ColIndex* with indicies starting at 0 with optional validation of
548 specified index values and return *Matrix*.
549
550 SetValuePrintFormat
551 $Matrix->SetValuePrintFormat($ValueFormat);
552 $Matrix::SetValuePrintFormat($ValueFormat);
553
554 Sets value print format for an individual object or the whole class
555 during StringifyMatrix operation and returns *Matrix*.
556
557 StringifyMatrix
558 $String = $Matrix->StringifyMatrix();
559
560 Returns a string containing information about *Matrix* object.
561
562 Transpose
563 $Matrix->Transpose();
564
565 Transposes *Matrix* by swaping rows with columns and returns
566 *Matrix*.
567
568 UnitMatrix
569 $NewUnitMatrix = $Matrix::UnitMatrix($NumOfRows, $NumOfCols);
570 $NewUnitMatrix = $Matrix::UnitMatrix();
571 $NewUnitMatrix = $Matrix->UnitMatrix($NumOfRows, $NumOfCols);
572
573 Creates a new UnitMatrix of specified size *NumOfRows x NumOfCol* or
574 of size 3 x 3 and returns NewUnitMatrix object.
575
576 Zero
577 $Matrix->Zero();
578
579 Sets values of all *Matrix* elements to 0 and returns *Matrix*.
580
581 ZeroMatrix
582 $NewZeroMatrix = $Matrix::ZeroMatrix($NumOfRows, $NumOfCols);
583 $NewZeroMatrix = $Matrix::ZeroMatrix();
584 $NewZeroMatrix = $Matrix->ZeroMatrix($NumOfRows, $NumOfCols);
585
586 Creates a new ZeroMatrix of specified size *NumOfRows x NumOfCol* or
587 of size 3 x 3 and returns NewZeroMatrix object.
588
589 AUTHOR
590 Manish Sud <msud@san.rr.com>
591
592 SEE ALSO
593 Vector.pm
594
595 COPYRIGHT
596 Copyright (C) 2015 Manish Sud. All rights reserved.
597
598 This file is part of MayaChemTools.
599
600 MayaChemTools is free software; you can redistribute it and/or modify it
601 under the terms of the GNU Lesser General Public License as published by
602 the Free Software Foundation; either version 3 of the License, or (at
603 your option) any later version.
604