/usr/include/linbox/matrix/matrix-domain.h is in liblinbox-dev 1.1.6~rc0-4.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* linbox/matrix/matrix-domain.h
* Copyright (C) 2002 Zhendong Wan, Bradford Hovinen
*
* Written by Zhendong Wan <wan@mail.eecis.udel.edu>,
* Bradford Hovinen <bghovinen@math.uwaterloo.ca>
*
* ------------------------------------------------------------
* 2002-11-26 Bradford Hovinen <bghovinen@math.uwaterloo.ca>
*
* Added detailed documentation, cleaned up the interface slightly, and added
* support for matrix traits. Added read, write, neg, negin, axpy, and
* matrix-vector and matrix-black box operations.
* ------------------------------------------------------------
*
* See COPYING for license information.
*/
#ifndef __MATRIX_DOMAIN_H
#define __MATRIX_DOMAIN_H
#include <iostream>
#include "linbox/blackbox/archetype.h"
#include "linbox/vector/vector-domain.h"
namespace LinBox
{
/** \brief For specializing matrix arithmetic
*
* This class defines matrix categories that allow us to specialize the matrix
* arithmetic in \ref MatrixDomain for different matrix representations. For
* example, a sparse matrix may have an efficient iterator over row vectors but
* not over column vectors. Therefore, an algorithm that tries to iterate over
* column vectors will run very slowly. Hence a specialization that avoids using
* column vectors is used instead.
*/
struct MatrixCategories
{
struct BlackboxTag { };
struct RowMatrixTag : public virtual BlackboxTag { };
struct ColMatrixTag : public virtual BlackboxTag { };
struct RowColMatrixTag : public RowMatrixTag, public ColMatrixTag { };
};
template <class Matrix> struct MatrixTraits
{
typedef Matrix MatrixType;
typedef typename Matrix::MatrixCategory MatrixCategory;
};
/** \brief Helper class to allow specializations of certain matrix-vector products
*
* This class implements a method mulColSPD that multiplies a
* column-represented matrix by a dense vector
*/
template <class Field>
class MVProductDomain
{
public:
typedef typename Field::Element Element;
MVProductDomain () {}
protected:
template <class Vector1, class Matrix, class Vector2>
inline Vector1 &mulColDense (const VectorDomain<Field> &VD, Vector1 &w, const Matrix &A, const Vector2 &v) const;
};
/** \brief Class of matrix arithmetic functions
*
* This class encapuslated matrix-matrix and matrix-vector operations, roughly
* equivalent to BLAS levels 2 and 3. The arithmetic methods are parameterized
* by matrix type so that they may be used the same way with sparse matrices,
* dense matrices, and dense submatrices. Except where otherwise noted, they
* require the matrix inputs to meet the \ref DenseMatrix archetype.
*
* These methods are specialized so that they can run efficiently with different
* matrix representations. If a matrix has an efficient row iterator, but not an
* efficient column iterator, a specialization that makes use of the former will
* be selected. This allows a great deal of flexibility when dealing with sparse
* matrix arithmetic.
*
* For all of the arithmetic operations that output matrices, it is assumed that
* the output matrix has an efficient row iterator. In typical use, the output
* matrix will be a \ref DenseMatrixBase or a \ref DenseSubmatrix, which has
* efficient row and column iterators. In particular, one should not perform
* these arithmetic operations outputting to a \ref SparseMatrixBase.
*
* There are other restrictions. See the method-specific documentation for more
* details.
*/
template <class Field>
class MatrixDomain : public MVProductDomain<Field>
{
public:
///
MatrixDomain (const Field &F) : _F (F), _VD (F) {}
/** Retrieve the underlying field
* Return a reference to the field that this matrix domain
* object uses
* @returns reference to field
*/
const Field &field () const
{ return _F; }
Field &field ()
{ return _F; }
/** Print matrix.
* @param os Output stream to which matrix is written.
* @param A Matrix.
* @returns reference to os.
*/
template <class Matrix>
inline std::ostream &write (std::ostream &os, const Matrix &A) const
{ return A.write (os, _F); }
/** Read matrix
* @param is Input stream from which matrix is read.
* @param A Matrix.
* @returns reference to is.
*/
template <class Matrix>
inline std::istream &read (std::istream &is, Matrix &A) const
{ return A.read (is, _F); }
/** Matrix copy
* B <- A
* Copy the contents of the matrix B to the matrix A
*
* Both matrices must support the same iterators, row or column.
*
* @param B Matrix B
* @param A Matrix A
* @returns Reference to B
*/
template <class Matrix1, class Matrix2>
inline Matrix1 © (Matrix1 &B, const Matrix2 &A) const
{ return copySpecialized (B, A,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory ()); }
/** Matrix equality
* Test whether the matrices A and B are equal
* @param A Input vector
* @param B Input vector
* @returns true if and only if the matrices A and B are equal
*/
template <class Matrix1, class Matrix2>
bool areEqual (const Matrix1 &A, const Matrix2 &B) const
{ return areEqualSpecialized (B, A,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory ()); }
/** Matrix equality with zero
* @param A Input matrix
* @returns true if and only if the matrix A is zero
*/
template <class Matrix>
inline bool isZero (const Matrix &A) const
{ return isZeroSpecialized (A, typename MatrixTraits<Matrix>::MatrixCategory ()); }
/** Matrix-matrix addition
* C <- A + B
*
* Each of A, B, and C must support the same iterator, either row or
* column
*
* @param C Output matrix C
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to C
*/
template <class Matrix1, class Matrix2, class Matrix3>
inline Matrix1& add (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const
{ return addSpecialized (C, A, B,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory (),
typename MatrixTraits<Matrix3>::MatrixCategory ()); }
/** Matrix-matrix in-place addition
* A <- A + B
*
* Each of A and B must support the same iterator, either row or column
*
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to A
*/
template <class Matrix1, class Matrix2>
inline Matrix1& addin (Matrix1 &A, const Matrix2 &B) const
{ return addinSpecialized (A, B,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory ()); }
/** Matrix-matrix subtraction
* C <- A - B
*
* Each of A, B, and C must support the same iterator, either row or
* column
*
* @param C Output matrix C
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to C
*/
template <class Matrix1, class Matrix2, class Matrix3>
inline Matrix1 &sub (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const
{ return subSpecialized (C, A, B,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory (),
typename MatrixTraits<Matrix3>::MatrixCategory ()); }
/** Matrix-matrix in-place subtraction
* A <- A - B
*
* Each of A and B must support the same iterator, either row or column
*
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to A
*/
template <class Matrix1, class Matrix2>
inline Matrix1 &subin (Matrix1 &A, const Matrix2 &B) const
{ return subinSpecialized (A, B,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory ()); }
/** Matrix negate
* B <- -A
*
* Each of A and B must support the same iterator, either row or column
*
* @param B Output matrix B
* @param A Input matrix A
* @returns reference to B
*/
template <class Matrix1, class Matrix2>
inline Matrix1 &neg (Matrix1 &B, const Matrix2 &A) const
{ return negSpecialized (B, A,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory ()); }
/** Matrix in-place negate
* A <- -A
* @param A Input matrix A; result is stored here
*/
template <class Matrix>
inline Matrix &negin (Matrix &A) const
{ return neginSpecialized (A, typename MatrixTraits<Matrix>::MatrixCategory ()); }
/** Matrix-matrix multiply
* C <- A * B
*
* C must support both row and column iterators, and the vector
* representations must be dense. Examples of supported matrices are
* \ref DenseMatrixBase and \ref DenseSubmatrix.
*
* Either A or B, or both, may have limited iterators. However, either A
* must support row iterators or B must support column iterators. If
* both A and B lack support for an iterator (either row or column),
* then C must support the same type of iterator as A and B.
*
* @param C Output matrix C
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to C
*/
template <class Matrix1, class Matrix2, class Matrix3>
inline Matrix1 &mul (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const
{ return mulSpecialized (C, A, B,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory (),
typename MatrixTraits<Matrix3>::MatrixCategory ()); }
/** Matrix-matrix in-place multiply on the left
* B <- A * B
*
* B should support both row and column iterators, and must be dense. A
* must support row iterators.
*
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to B
*/
template <class Matrix1, class Matrix2>
inline Matrix2 &leftMulin (const Matrix1 &A, Matrix2 &B) const;
/** Matrix-matrix in-place multiply on the right
* A <- A * B
*
* A should support both row and column iterators, and must be dense. B
* must support column iterators.
*
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to A
*/
template <class Matrix1, class Matrix2>
inline Matrix1 &rightMulin (Matrix1 &A, const Matrix2 &B) const;
/** Matrix-matrix in-place multiply
* A <- A * B
*
* This is an alias for \ref rightMulin
*
* @param A Input matrix A
* @param B Input matrix B
* @returns Reference to A
*/
template <class Matrix1, class Matrix2>
inline Matrix1 &mulin (Matrix1 &A, const Matrix2 &B) const
{ return rightMulin (A, B); }
/** Matrix-scalar multiply
* C <- B * a
*
* Multiply B by the scalar element a and store the result in C. B and C
* must support the same iterators.
*
* @param C Output matrix C
* @param B Input matrix B
* @param a Input scalar a
* @returns Reference to C
*/
template <class Matrix1, class Matrix2>
inline Matrix1 &mul (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a) const
{ return mulSpecialized (C, B, a,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory ()); }
/** Matrix-scalar in-place multiply
* B <- B * a
*
* Multiply B by the scalar element a in-place.
*
* @param B Input matrix B
* @param a Input scalar a
* @returns Reference to B
*/
template <class Matrix>
inline Matrix &mulin (Matrix &B, const typename Field::Element &a) const
{ return mulinSpecialized (B, a, typename MatrixTraits<Matrix>::MatrixCategory ()); }
/** Matrix-matrix in-place axpy
* Y <- Y + A*X
*
* This function combines \ref mul and \ref add, eliminating the need
* for an additional temporary in expressions of the form $Y = Y +
* AX$. Only one row of additional storage is required. Y may have
* either efficient row iterators or efficient column iterators, and the
* same restrictions on A and X apply as in \ref mul.
*
* Note that no out-of-place axpy is provided, since it gives no
* benefit. One may just as easily multiply into the result and call
* \ref addin.
*
* @param Y Input matrix Y; result is stored here
* @param A Input matrix A
* @param X Input matrix X
*/
template <class Matrix1, class Matrix2, class Matrix3>
inline Matrix1 &axpyin (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const
{ return axpyinSpecialized (Y, A, X,
typename MatrixTraits<Matrix1>::MatrixCategory (),
typename MatrixTraits<Matrix2>::MatrixCategory (),
typename MatrixTraits<Matrix3>::MatrixCategory ()); }
/* FIXME: Need documentation of these methods */
template<class Matrix1, class Matrix2>
Matrix1 &pow_apply (Matrix1 &M1, const Matrix2 &M2, unsigned long int k) const;
template<class Matrix1, class Matrix2>
Matrix1 &pow_horn (Matrix1 &M1, const Matrix2 &M2, unsigned long int k) const;
/* @name Matrix-vector arithmetic operations
* These operations take a matrix satisfying the \ref DenseMatrix
* archetype and LinBox vectors as inputs. They involve matrix-vector
* product and matrix-vector AXPY
*/
/** Matrix-vector multiply
* w <- A * v
*
* The vectors v and w must be of the same representation (dense, sparse
* sequence, sparse associative, or sparse parallel), but they may be of
* different types. The matrix A may have any representation.
*
* @param w Output vector w
* @param A Input matrix A
* @param v Input vector v
* @returns Reference to w
*/
template <class Vector1, class Matrix, class Vector2>
inline Vector1 &vectorMul (Vector1 &w, const Matrix &A, const Vector2 &v) const
{ return mulSpecialized (w, A, v, typename MatrixTraits<Matrix>::MatrixCategory ()); }
/** Matrix-vector in-place axpy
* y <- y + A*x
*
* This function eliminates the requirement for temporary storage when
* one is computing an expression of the form given above.
*
* The vectors y and x must be of the same representation (dense, sparse
* sequence, sparse associative, or sparse parallel), but they may be of
* different types. The matrix A may have any representation.
*
* Note that out-of-place axpy is not provided since it provides no
* benefit -- one can use mul and then addin to exactly the same effect,
* with no additional storage or performance cost.
*
* @param y Input vector y; result is stored here
* @param A Input matrix A
* @param x Input vector x
*/
template <class Vector1, class Matrix, class Vector2>
inline Vector1 &vectorAxpyin (Vector1 &y, const Matrix &A, const Vector2 &x) const
{ return axpyinSpecialized (y, A, x, typename MatrixTraits<Matrix>::MatrixCategory ()); }
/*? @name Matrix-black box arithmetic operations
* These operations mimic the matrix-matrix arithmetic operations above,
* but one of the parameters is a \ref BlackboxArchetype.
*/
/** Matrix-black box left-multiply
* C <- A * B
*
* Both C and B must support column iterators
*
* @param C Output matrix
* @param A Black box for A
* @param B Matrix B
*/
template <class Matrix1, class Blackbox, class Matrix2>
inline Matrix1 &blackboxMulLeft (Matrix1 &C, const Blackbox &A, const Matrix2 &B) const;
/** Matrix-black box right-multiply
* C <- A * B
*
* Both C and A must support row iterators
*
* @param C Output matrix
* @param A Matrix A
* @param B Black box for B
*/
template <class Matrix1, class Matrix2, class Blackbox>
inline Matrix1 &blackboxMulRight (Matrix1 &C, const Matrix2 &A, const Blackbox &B) const;
/*? @name Matrix permutations
* These operations permute the rows or columns of a matrix based on
* the given permutation. They are intended for use with Gauss-Jordan
* elimination
*/
/** Permutation
*
* A permutation is represented as a vector of pairs, each
* pair representing a transposition.
*/
typedef std::pair<unsigned int, unsigned int> Transposition;
typedef std::vector<Transposition> Permutation;
/** Permute the rows of the given matrix
*
* @param A Output matrix
* @param P_start Start of permutation
* @param P_end End of permutation
* @returns Reference to A
*/
template <class Matrix, class Iterator>
inline Matrix &permuteRows (Matrix &A,
Iterator P_start,
Iterator P_end) const
{ return permuteRowsSpecialized (A, P_start, P_end,
typename MatrixTraits<Matrix>::MatrixCategory ()); }
/** Permute the columns of the given matrix
*
* @param A Output matrix
* @param P_start Start of permutation
* @param P_end End of permutation
* @returns Reference to A
*/
template <class Matrix, class Iterator>
inline Matrix &permuteColumns (Matrix &A,
Iterator P_start,
Iterator P_end) const
{ return permuteColsSpecialized (A, P_start, P_end,
typename MatrixTraits<Matrix>::MatrixCategory ()); }
private:
// Specialized function implementations
template <class Matrix1, class Matrix2> Matrix1 ©Row (Matrix1 &B, const Matrix2 &A) const;
template <class Matrix1, class Matrix2> Matrix1 ©Col (Matrix1 &B, const Matrix2 &A) const;
template <class Matrix1, class Matrix2>
inline Matrix1 ©Specialized (Matrix1 &B, const Matrix2 &A,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return copyRow (B, A); }
template <class Matrix1, class Matrix2>
inline Matrix1 ©Specialized (Matrix1 &B, const Matrix2 &A,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return copyCol (B, A); }
template <class Matrix1, class Matrix2>
inline Matrix1 ©Specialized (Matrix1 &B, const Matrix2 &A,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return copyRow (B, A); }
template <class Matrix1, class Matrix2> bool areEqualRow (const Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2> bool areEqualCol (const Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2>
inline bool areEqualSpecialized (const Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return areEqualRow (A, B); }
template <class Matrix1, class Matrix2>
inline bool areEqualSpecialized (const Matrix1 &A, const Matrix2 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return areEqualCol (A, B); }
template <class Matrix1, class Matrix2>
inline bool areEqualSpecialized (const Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return areEqualRow (A, B); }
template <class Matrix> bool isZeroRow (const Matrix &v) const;
template <class Matrix> bool isZeroCol (const Matrix &v) const;
template <class Matrix>
bool isZeroSpecialized (const Matrix &A, MatrixCategories::RowMatrixTag) const
{ return isZeroRow (A); }
template <class Matrix>
bool isZeroSpecialized (const Matrix &A, MatrixCategories::ColMatrixTag) const
{ return isZeroCol (A); }
template <class Matrix>
bool isZeroSpecialized (const Matrix &A, MatrixCategories::RowColMatrixTag) const
{ return isZeroRow (A); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& addRow (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& addCol (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& addSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return addRow (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& addSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return addCol (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& addSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return addRow (C, A, B); }
template <class Matrix1, class Matrix2> Matrix1& addinRow (Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2> Matrix1& addinCol (Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2>
inline Matrix1& addinSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return addinRow (A, B); }
template <class Matrix1, class Matrix2>
inline Matrix1& addinSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return addinCol (A, B); }
template <class Matrix1, class Matrix2>
inline Matrix1& addinSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return addinRow (A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& subRow (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& subCol (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& subSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return subRow (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& subSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return subCol (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1& subSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return subRow (C, A, B); }
template <class Matrix1, class Matrix2> Matrix1& subinRow (Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2> Matrix1& subinCol (Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2>
Matrix1& subinSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return subinRow (A, B); }
template <class Matrix1, class Matrix2>
Matrix1& subinSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return subinCol (A, B); }
template <class Matrix1, class Matrix2>
Matrix1& subinSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return subinRow (A, B); }
template <class Matrix1, class Matrix2> Matrix1& negRow (Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2> Matrix1& negCol (Matrix1 &A, const Matrix2 &B) const;
template <class Matrix1, class Matrix2>
inline Matrix1& negSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return negRow (A, B); }
template <class Matrix1, class Matrix2>
inline Matrix1& negSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return negCol (A, B); }
template <class Matrix1, class Matrix2>
inline Matrix1& negSpecialized (Matrix1 &A, const Matrix2 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return negRow (A, B); }
template <class Matrix> Matrix &neginRow (Matrix &A) const;
template <class Matrix> Matrix &neginCol (Matrix &A) const;
template <class Matrix>
Matrix &neginSpecialized (Matrix &A, MatrixCategories::RowMatrixTag) const
{ return neginRow (A); }
template <class Matrix>
Matrix &neginSpecialized (Matrix &A, MatrixCategories::ColMatrixTag) const
{ return neginCol (A); }
template <class Matrix>
Matrix &neginSpecialized (Matrix &A, MatrixCategories::RowColMatrixTag) const
{ return neginRow (A); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulRowRowCol (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulColRowCol (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulRowRowRow (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulColColCol (Matrix1 &C, const Matrix2 &A, const Matrix3 &B) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return mulRowRowCol (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return mulColRowCol (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return mulRowRowCol (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return mulRowRowRow (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return mulColColCol (C, A, B); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &A, const Matrix3 &B,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return mulRowRowCol (C, A, B); }
template <class Matrix1, class Matrix2>
Matrix1 &mulRow (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a) const;
template <class Matrix1, class Matrix2>
Matrix1 &mulCol (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a) const;
template <class Matrix1, class Matrix2>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return mulRow (C, B, a); }
template <class Matrix1, class Matrix2>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return mulCol (C, B, a); }
template <class Matrix1, class Matrix2>
Matrix1 &mulSpecialized (Matrix1 &C, const Matrix2 &B, const typename Field::Element &a,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return mulRow (C, B, a); }
template <class Matrix> Matrix &mulinRow (Matrix &B, const typename Field::Element &a) const;
template <class Matrix> Matrix &mulinCol (Matrix &B, const typename Field::Element &a) const;
template <class Matrix>
Matrix &mulinSpecialized (Matrix &B, const typename Field::Element &a,
MatrixCategories::RowMatrixTag) const
{ return mulinRow (B, a); }
template <class Matrix>
Matrix &mulinSpecialized (Matrix &B, const typename Field::Element &a,
MatrixCategories::ColMatrixTag) const
{ return mulinCol (B, a); }
template <class Matrix>
Matrix &mulinSpecialized (Matrix &B, const typename Field::Element &a,
MatrixCategories::RowColMatrixTag) const
{ return mulinRow (B, a); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinRowRowCol (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinColRowCol (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinRowRowRow (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinColColCol (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X) const;
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinSpecialized (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return axpyinRowRowCol (Y, A, X); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinSpecialized (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X,
MatrixCategories::ColMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return axpyinColRowCol (Y, A, X); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinSpecialized (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return axpyinRowRowCol (Y, A, X); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinSpecialized (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag,
MatrixCategories::RowMatrixTag) const
{ return axpyinRowRowRow (Y, A, X); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinSpecialized (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag,
MatrixCategories::ColMatrixTag) const
{ return axpyinColColCol (Y, A, X); }
template <class Matrix1, class Matrix2, class Matrix3>
Matrix1 &axpyinSpecialized (Matrix1 &Y, const Matrix2 &A, const Matrix3 &X,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag,
MatrixCategories::RowColMatrixTag) const
{ return axpyinRowRowCol (Y, A, X); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulRowSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::DenseVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulRowSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::SparseSequenceVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulRowSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::SparseAssociativeVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulRowSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::SparseParallelVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulColSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::DenseVectorTag,
VectorCategories::DenseVectorTag) const
{ return mulColDense (_VD, w, A, v); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulColSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::DenseVectorTag,
VectorCategories::SparseSequenceVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulColSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::DenseVectorTag,
VectorCategories::SparseAssociativeVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulColSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::DenseVectorTag,
VectorCategories::SparseParallelVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
inline Vector1 &mulColSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
VectorCategories::GenericVectorTag,
VectorCategories::GenericVectorTag) const
{
typename LinBox::Vector<Field>::Dense y;
VectorWrapper::ensureDim (y, w.size ());
VectorWrapper::ensureDim (y, w.size ());
vectorMul (y, A, v);
_VD.copy (w, y);
return w;
}
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
MatrixCategories::RowMatrixTag) const
{ return mulRowSpecialized (w, A, v, typename VectorTraits<Vector1>::VectorCategory ()); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
MatrixCategories::ColMatrixTag) const
{ return mulColSpecialized (w, A, v,
typename VectorTraits<Vector1>::VectorCategory (),
typename VectorTraits<Vector2>::VectorCategory ()); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &mulSpecialized (Vector1 &w, const Matrix &A, const Vector2 &v,
MatrixCategories::RowColMatrixTag) const
{ return mulRowSpecialized (w, A, v, typename VectorTraits<Vector1>::VectorCategory ()); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinRowSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::DenseVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinRowSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::SparseSequenceVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinRowSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::SparseAssociativeVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinRowSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::SparseParallelVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinColSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::DenseVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinColSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::SparseSequenceVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinColSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::SparseAssociativeVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinColSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
VectorCategories::SparseParallelVectorTag) const;
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
MatrixCategories::RowMatrixTag) const
{ return axpyinRowSpecialized (y, A, x, typename VectorTraits<Vector1>::VectorCategory ()); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
MatrixCategories::ColMatrixTag) const
{ return axpyinColSpecialized (y, A, x, typename VectorTraits<Vector1>::VectorCategory ()); }
template <class Vector1, class Matrix, class Vector2>
Vector1 &axpyinSpecialized (Vector1 &y, const Matrix &A, const Vector2 &x,
MatrixCategories::RowColMatrixTag) const
{ return axpyinRowSpecialized (y, A, x, typename VectorTraits<Vector1>::VectorCategory ()); }
template <class Matrix, class Iterator>
inline Matrix &permuteRowsByRow (Matrix &A,
Iterator P_start,
Iterator P_end) const;
template <class Matrix, class Iterator>
inline Matrix &permuteRowsByCol (Matrix &A,
Iterator P_start,
Iterator P_end) const;
template <class Matrix, class Iterator>
inline Matrix &permuteRowsSpecialized (Matrix &A,
Iterator P_start,
Iterator P_end,
MatrixCategories::RowColMatrixTag) const
{ return permuteRowsByCol (A, P_start, P_end); }
template <class Matrix, class Iterator>
inline Matrix &permuteRowsSpecialized (Matrix &A,
Iterator P_start,
Iterator P_end,
MatrixCategories::RowMatrixTag) const
{ return permuteRowsByRow (A, P_start, P_end); }
template <class Matrix, class Iterator>
inline Matrix &permuteRowsSpecialized (Matrix &A,
Iterator P_start,
Iterator P_end,
MatrixCategories::ColMatrixTag) const
{ return permuteRowsByCol (A, P_start, P_end); }
template <class Matrix, class Iterator>
inline Matrix &permuteColsByRow (Matrix &A,
Iterator P_start,
Iterator P_end) const;
template <class Matrix, class Iterator>
inline Matrix &permuteColsByCol (Matrix &A,
Iterator P_start,
Iterator P_end) const;
template <class Matrix, class Iterator>
inline Matrix &permuteColsSpecialized (Matrix &A,
Iterator P_start,
Iterator P_end,
MatrixCategories::RowColMatrixTag) const
{ return permuteColsByRow (A, P_start, P_end); }
template <class Matrix, class Iterator>
inline Matrix &permuteColsSpecialized (Matrix &A,
Iterator P_start,
Iterator P_end,
MatrixCategories::RowMatrixTag) const
{ return permuteColsByRow (A, P_start, P_end); }
template <class Matrix, class Iterator>
inline Matrix &permuteColsSpecialized (Matrix &A,
Iterator P_start,
Iterator P_end,
MatrixCategories::ColMatrixTag) const
{ return permuteColsByCol (A, P_start, P_end); }
const Field &_F;
VectorDomain<Field> _VD;
};
}
#include "linbox/matrix/matrix-domain.inl"
#endif // __MATRIX_DOMAIN_H
|