~ubuntu-branches/ubuntu/trusty/deal.ii/trusty

« back to all changes in this revision

Viewing changes to lac/include/lac/full_matrix.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV, Adam C. Powell, IV, Denis Barbier
  • Date: 2010-07-29 13:47:01 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100729134701-akb8jb3stwge8tcm
Tags: 6.3.1-1
[ Adam C. Powell, IV ]
* Changed to source format 3.0 (quilt).
* Changed maintainer to debian-science with Adam Powell as uploader.
* Added source lintian overrides about Adam Powell's name.
* Added Vcs info on git repository.
* Bumped Standards-Version.
* Changed stamp-patch to patch target and fixed its application criterion.
* Moved make_dependencies and expand_instantiations to a versioned directory
  to avoid shlib package conflicts.

[ Denis Barbier ]
* New upstream release (closes: #562332).
  + Added libtbb support.
  + Forward-ported all patches.
* Updates for new PETSc version, including workaround for different versions
  of petsc and slepc.
* Add debian/watch.
* Update to debhelper 7.
* Added pdebuild patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//---------------------------------------------------------------------------
2
 
//    $Id: full_matrix.h 17866 2008-12-05 22:27:44Z bangerth $
 
2
//    $Id: full_matrix.h 20220 2009-12-09 18:12:05Z kronbichler $
3
3
//    Version: $Name$
4
4
//
5
 
//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
 
5
//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
6
6
//
7
7
//    This file is subject to QPL and may not be  distributed
8
8
//    without copyright and license information. Please refer
678
678
                                      * inverse of the given factor.
679
679
                                      */
680
680
    FullMatrix & operator /= (const number factor);
681
 
    
 
681
 
682
682
                                     /**
683
683
                                      * Simple addition of a scaled
684
684
                                      * matrix, i.e. <tt>*this +=
694
694
    template<typename number2>
695
695
    void add (const number               a,
696
696
              const FullMatrix<number2> &A);
697
 
    
 
697
 
698
698
                                     /**
699
699
                                      * Multiple addition of scaled
700
700
                                      * matrices, i.e. <tt>*this +=
713
713
              const FullMatrix<number2> &A,
714
714
              const number               b,
715
715
              const FullMatrix<number2> &B);
716
 
    
 
716
 
717
717
                                     /**
718
718
                                      * Multiple addition of scaled
719
719
                                      * matrices, i.e. <tt>*this +=
734
734
              const FullMatrix<number2> &B,
735
735
              const number               c,
736
736
              const FullMatrix<number2> &C);
737
 
    
 
737
 
738
738
                                     /**
739
739
                                      * Add rectangular block.
740
740
                                      *
759
759
              const unsigned int dst_offset_j = 0,
760
760
              const unsigned int src_offset_i = 0,
761
761
              const unsigned int src_offset_j = 0);
762
 
    
 
762
 
763
763
                                     /**
764
764
                                      * Weighted addition of the
765
765
                                      * transpose of <tt>B</tt> to
770
770
    template<typename number2>
771
771
    void Tadd (const number               s,
772
772
               const FullMatrix<number2> &B);
773
 
    
 
773
 
774
774
                                     /**
775
 
                                      * Add transose of a rectangular block.
 
775
                                      * Add transpose of a rectangular block.
776
776
                                      *
777
777
                                      * A rectangular block of the
778
778
                                      * matrix <tt>src</tt> is
941
941
    void invert (const FullMatrix<number2> &M);
942
942
 
943
943
                                     /**
 
944
                                      * Assign the Cholesky decomposition
 
945
                                      * of the given matrix to <tt>*this</tt>. 
 
946
                                      * The given matrix must be symmetric
 
947
                                      * positive definite.
 
948
                                      *
 
949
                                      * ExcMatrixNotPositiveDefinite
 
950
                                      * will be thrown in the case that the
 
951
                                      * matrix is not positive definite.
 
952
                                      */
 
953
    template <typename number2>
 
954
    void cholesky (const FullMatrix<number2> &A);
 
955
 
 
956
                                     /**
 
957
                                      * <tt>*this(i,j)</tt> = $V(i) W(j)$ 
 
958
                                      * where $V,W$
 
959
                                      * are vectors of the same length.
 
960
                                      */
 
961
    template <typename number2>
 
962
    void outer_product (const Vector<number2> &V,
 
963
                        const Vector<number2> &W);
 
964
    
 
965
                                     /**
944
966
                                      * Assign the left_inverse of the given matrix
945
967
                                      * to <tt>*this</tt>. The calculation being 
946
968
                                      * performed is <i>(A<sup>T</sup>*A)<sup>-1</sup>
1008
1030
//@}
1009
1031
///@name Multiplications
1010
1032
//@{
1011
 
    
 
1033
 
1012
1034
                                     /**
1013
1035
                                      * Matrix-matrix-multiplication.
1014
1036
                                      *
1023
1045
                                      * if (!adding)
1024
1046
                                      *  <i>C = A*B</i>
1025
1047
                                      *
1026
 
                                      * Assumes that <tt>A</tt> and <tt>B</tt> have
1027
 
                                      * compatible sizes and that <tt>C</tt>
1028
 
                                      * already has the right size.
 
1048
                                      * Assumes that <tt>A</tt> and
 
1049
                                      * <tt>B</tt> have compatible sizes and
 
1050
                                      * that <tt>C</tt> already has the
 
1051
                                      * right size.
 
1052
                                      *
 
1053
                                      * This function uses the BLAS function
 
1054
                                      * Xgemm if the calling matrix has more
 
1055
                                      * than 15 rows and BLAS was detected
 
1056
                                      * during configuration. Using BLAS
 
1057
                                      * usually results in considerable
 
1058
                                      * performance gains.
1029
1059
                                      */
1030
1060
    template<typename number2>
1031
1061
    void mmult (FullMatrix<number2>       &C,
1051
1081
                                      * <tt>B</tt> have compatible
1052
1082
                                      * sizes and that <tt>C</tt>
1053
1083
                                      * already has the right size.
 
1084
                                      *
 
1085
                                      * This function uses the BLAS function
 
1086
                                      * Xgemm if the calling matrix has more
 
1087
                                      * than 15 columns and BLAS was
 
1088
                                      * detected during configuration. Using
 
1089
                                      * BLAS usually results in considerable
 
1090
                                      * performance gains.
1054
1091
                                      */
1055
1092
    template<typename number2>
1056
1093
    void Tmmult (FullMatrix<number2>       &C,
1057
1094
                 const FullMatrix<number2> &B,
1058
1095
                 const bool                 adding=false) const;
 
1096
 
 
1097
                                     /**
 
1098
                                      * Matrix-matrix-multiplication using
 
1099
                                      * transpose of <tt>B</tt>.
 
1100
                                      *
 
1101
                                      * The optional parameter
 
1102
                                      * <tt>adding</tt> determines, whether the
 
1103
                                      * result is stored in <tt>C</tt> or added
 
1104
                                      * to <tt>C</tt>.
 
1105
                                      *
 
1106
                                      * if (adding)
 
1107
                                      *  <i>C += A*B<sup>T</sup></i>
 
1108
                                      *
 
1109
                                      * if (!adding)
 
1110
                                      *  <i>C = A*B<sup>T</sup></i>
 
1111
                                      *
 
1112
                                      * Assumes that <tt>A</tt> and
 
1113
                                      * <tt>B</tt> have compatible sizes and
 
1114
                                      * that <tt>C</tt> already has the
 
1115
                                      * right size.
 
1116
                                      *
 
1117
                                      * This function uses the BLAS function
 
1118
                                      * Xgemm if the calling matrix has more
 
1119
                                      * than 15 rows and BLAS was detected
 
1120
                                      * during configuration. Using BLAS
 
1121
                                      * usually results in considerable
 
1122
                                      * performance gains.
 
1123
                                      */
 
1124
    template<typename number2>
 
1125
    void mTmult (FullMatrix<number2>       &C,
 
1126
                 const FullMatrix<number2> &B,
 
1127
                 const bool                 adding=false) const;
 
1128
    
 
1129
                                     /**
 
1130
                                      * Matrix-matrix-multiplication using
 
1131
                                      * transpose of <tt>this</tt> and
 
1132
                                      * <tt>B</tt>.
 
1133
                                      *
 
1134
                                      * The optional parameter
 
1135
                                      * <tt>adding</tt> determines, whether the
 
1136
                                      * result is stored in <tt>C</tt> or added
 
1137
                                      * to <tt>C</tt>.
 
1138
                                      *
 
1139
                                      * if (adding)
 
1140
                                      *  <i>C += A<sup>T</sup>*B<sup>T</sup></i>
 
1141
                                      *
 
1142
                                      * if (!adding)
 
1143
                                      *  <i>C = A<sup>T</sup>*B<sup>T</sup></i>
 
1144
                                      *
 
1145
                                      * Assumes that <tt>A</tt> and
 
1146
                                      * <tt>B</tt> have compatible
 
1147
                                      * sizes and that <tt>C</tt>
 
1148
                                      * already has the right size.
 
1149
                                      *
 
1150
                                      * This function uses the BLAS function
 
1151
                                      * Xgemm if the calling matrix has more
 
1152
                                      * than 15 columns and BLAS was
 
1153
                                      * detected during configuration. Using
 
1154
                                      * BLAS usually results in considerable
 
1155
                                      * performance gains.
 
1156
                                      */
 
1157
    template<typename number2>
 
1158
    void TmTmult (FullMatrix<number2>       &C,
 
1159
                  const FullMatrix<number2> &B,
 
1160
                  const bool                 adding=false) const;
1059
1161
    
1060
1162
                                     /**
1061
1163
                                      * Matrix-vector-multiplication.
1219
1321
                                      * Exception
1220
1322
                                      */
1221
1323
    DeclException0 (ExcSourceEqualsDestination);
 
1324
                                     /**
 
1325
                                      * Exception
 
1326
                                      */
 
1327
    DeclException0 (ExcMatrixNotPositiveDefinite);
1222
1328
                                     //@}
1223
1329
    
1224
1330
    friend class Accessor;
1259
1365
  Assert (d==number(0), ExcScalarAssignmentOnlyForZeroValue());
1260
1366
 
1261
1367
  if (this->n_elements() != 0)
1262
 
    std::fill_n (this->val, this->n_elements(), number());
 
1368
    memset (this->val, 0, this->n_elements()*sizeof(number));
1263
1369
 
1264
1370
  return *this;
1265
1371
}