MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_MatrixOp.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #include <assert.h>
43 #include <math.h>
44 
45 #include <typeinfo>
46 #include <stdexcept>
47 
59 #include "Teuchos_Assert.hpp"
60 #include "Teuchos_FancyOStream.hpp"
61 
62 namespace AbstractLinAlgPack {
63 
65 {
67  true, std::logic_error, "MatrixOp::zero_out(): "
68  "Error, this method as not been defined by the subclass \'"
69  <<typeName(*this)<<"\'" );
70 }
71 
73 {
75  true, std::logic_error, "MatrixOp::Mt_S(): "
76  "Error, this method as not been defined by the subclass \'"
77  <<typeName(*this)<<"\'" );
78 }
79 
81 {
82  const bool assign_to_self = dynamic_cast<const void*>(this) == dynamic_cast<const void*>(&M);
84  !assign_to_self, std::logic_error
85  ,"MatrixOp::operator=(M) : Error, this is not assignment "
86  "to self and this method is not overridden for the subclass \'"
87  << typeName(*this) << "\'" );
88  return *this; // assignment to self
89 }
90 
91 std::ostream& MatrixOp::output(std::ostream& out_arg) const
92 {
93  Teuchos::RCP<Teuchos::FancyOStream> out = Teuchos::getFancyOStream(Teuchos::rcp(&out_arg,false));
94  Teuchos::OSTab tab(out);
95  const size_type m = this->rows(), n = this->cols();
97  row_vec = space_rows().create_member(); // dim() == n
98  *out << m << " " << n << std::endl;
99  for( size_type i = 1; i <= m; ++i ) {
100  LinAlgOpPack::V_StMtV( &*row_vec, 1.0, *this, BLAS_Cpp::trans, EtaVector(i,m)() );
101  row_vec->output(*out,false,true);
102  }
103  return out_arg;
104 }
105 
106 // Clone
107 
108 MatrixOp::mat_mut_ptr_t
110 {
111  return Teuchos::null;
112 }
113 
114 MatrixOp::mat_ptr_t
116 {
117  return Teuchos::null;
118 }
119 
120 // Norms
121 
122 const MatrixOp::MatNorm
124  EMatNormType requested_norm_type
125  ,bool allow_replacement
126  ) const
127 {
128  using BLAS_Cpp::no_trans;
129  using BLAS_Cpp::trans;
130  using LinAlgOpPack::V_MtV;
131  const VectorSpace
132  &space_cols = this->space_cols(),
133  &space_rows = this->space_rows();
134  const index_type
135  num_rows = space_cols.dim(),
136  num_cols = space_rows.dim();
138  !(requested_norm_type == MAT_NORM_1 || requested_norm_type == MAT_NORM_INF), MethodNotImplemented
139  ,"MatrixOp::calc_norm(...): Error, This default implemenation can only "
140  "compute the one norm or the infinity norm!"
141  );
142  //
143  // Here we implement Algorithm 2.5 in "Applied Numerical Linear Algebra", Demmel (1997)
144  // using the momenclature in the text.
145  //
146  const MatrixOp
147  &B = *this;
148  bool
149  do_trans = requested_norm_type == MAT_NORM_INF;
151  x = (!do_trans ? space_rows : space_cols).create_member(1.0/(!do_trans ? num_cols : num_rows)),
152  w = (!do_trans ? space_cols : space_rows).create_member(),
153  zeta = (!do_trans ? space_cols : space_rows).create_member(),
154  z = (!do_trans ? space_rows : space_cols).create_member();
155  const index_type max_iter = 5; // Recommended by Highman 1988, (see Demmel's reference)
156  value_type w_nrm = 0.0;
157  for( index_type k = 0; k <= max_iter; ++k ) {
158  V_MtV( w.get(), B, !do_trans ? no_trans : trans, *x ); // w = B*x
159  sign( *w, zeta.get() ); // zeta = sign(w)
160  V_MtV( z.get(), B, !do_trans ? trans : no_trans, *zeta ); // z = B'*zeta
161  value_type z_j = 0.0; // max |z(j)| = ||z||inf
162  index_type j = 0;
163  max_abs_ele( *z, &z_j, &j );
164  const value_type zTx = dot(*z,*x); // z'*x
165  w_nrm = w->norm_1(); // ||w||1
166  if( ::fabs(z_j) <= zTx ) { // Update
167  break;
168  }
169  else {
170  *x = 0.0;
171  x->set_ele(j,1.0);
172  }
173  }
174  return MatNorm(w_nrm,requested_norm_type);
175 }
176 
177 // Subview
178 
179 MatrixOp::mat_ptr_t
180 MatrixOp::sub_view(const Range1D& row_rng, const Range1D& col_rng) const
181 {
182  namespace rcp = MemMngPack;
183 
184  if(
185  ( ( row_rng.lbound() == 1 && row_rng.ubound() == this->rows() )
186  || row_rng.full_range() )
187  &&
188  ( ( col_rng.lbound() == 1 && col_rng.ubound() == this->cols() )
189  || row_rng.full_range() )
190  )
191  {
192  return Teuchos::rcp(this,false); // don't clean up memory
193  }
194  return Teuchos::rcp(
195  new MatrixOpSubView(
196  Teuchos::rcp(const_cast<MatrixOp*>(this),false) // don't clean up memory
197  ,row_rng,col_rng ) );
198 }
199 
200 // Permuted views
201 
202 MatrixOp::mat_ptr_t
204  const Permutation *P_row
205  ,const index_type row_part[]
206  ,int num_row_part
207  ,const Permutation *P_col
208  ,const index_type col_part[]
209  ,int num_col_part
210  ) const
211 {
212  namespace rcp = MemMngPack;
213  return Teuchos::rcp(
214  new MatrixPermAggr(
215  Teuchos::rcp(this,false)
216  ,Teuchos::rcp(P_row,false)
217  ,Teuchos::rcp(P_col,false)
219  ) );
220 }
221 
222 MatrixOp::mat_ptr_t
224  const Permutation *P_row
225  ,const index_type row_part[]
226  ,int num_row_part
227  ,const Permutation *P_col
228  ,const index_type col_part[]
229  ,int num_col_part
230  ,const mat_ptr_t &perm_view
231  ) const
232 {
233  return this->perm_view(
234  P_row,row_part,num_row_part
235  ,P_col,col_part,num_col_part );
236 }
237 
238 // Level-1 BLAS
239 
241  MatrixOp* m_lhs, value_type alpha
242  , BLAS_Cpp::Transp trans_rhs) const
243 {
244  return false;
245 }
246 
248  value_type alpha,const MatrixOp& M_rhs, BLAS_Cpp::Transp trans_rhs)
249 {
250  return false;
251 }
252 
254  MatrixOp* m_lhs, value_type alpha
255  , BLAS_Cpp::Transp M_trans
256  , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
257  ) const
258 {
259  return false;
260 }
261 
263  value_type alpha
264  ,const MatrixOp& M_rhs, BLAS_Cpp::Transp M_trans
265  ,const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
266  )
267 {
268  return false;
269 }
270 
272  MatrixOp* m_lhs, value_type alpha
273  , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
274  , BLAS_Cpp::Transp M_trans
275  ) const
276 {
277  return false;
278 }
279 
281  value_type alpha
282  ,const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
283  ,const MatrixOp& M_rhs, BLAS_Cpp::Transp M_trans
284  )
285 {
286  return false;
287 }
288 
290  MatrixOp* m_lhs, value_type alpha
291  , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
292  , BLAS_Cpp::Transp M_trans
293  , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
294  ) const
295 {
296  return false;
297 }
298 
300  value_type alpha
301  ,const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
302  ,const MatrixOp& M_rhs, BLAS_Cpp::Transp M_trans
303  ,const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
304  )
305 {
306  return false;
307 }
308 
309 // Level-2 BLAS
310 
312  VectorMutable* v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
313  , const SpVectorSlice& sv_rhs2, value_type beta) const
314 {
315  Vp_MtV_assert_compatibility(v_lhs,*this,trans_rhs1,sv_rhs2 );
316  if( sv_rhs2.nz() ) {
318  v_rhs2 = (trans_rhs1 == BLAS_Cpp::no_trans
319  ? this->space_rows()
320  : this->space_cols()
321  ).create_member();
322  v_rhs2->set_sub_vector(sub_vec_view(sv_rhs2));
323  this->Vp_StMtV(v_lhs,alpha,trans_rhs1,*v_rhs2,beta);
324  }
325  else {
326  Vt_S( v_lhs, beta );
327  }
328 }
329 
332  ,const GenPermMatrixSlice& P, BLAS_Cpp::Transp P_trans
333  ,BLAS_Cpp::Transp M_trans
334  ,const Vector& x, value_type b
335  ) const
336 {
338  t = ( M_trans == BLAS_Cpp::no_trans
339  ? this->space_cols()
340  : this->space_rows() ).create_member();
341  LinAlgOpPack::V_MtV( t.get(), *this, M_trans, x );
342  AbstractLinAlgPack::Vp_StMtV( y, a, P, P_trans, *t, b );
343 }
344 
347  ,const GenPermMatrixSlice& P, BLAS_Cpp::Transp P_trans
348  ,BLAS_Cpp::Transp M_trans
349  ,const SpVectorSlice& x, value_type b
350  ) const
351 {
353  t = ( M_trans == BLAS_Cpp::no_trans
354  ? this->space_cols()
355  : this->space_rows() ).create_member();
356  LinAlgOpPack::V_MtV( t.get(), *this, M_trans, x );
357  AbstractLinAlgPack::Vp_StMtV( y, a, P, P_trans, *t, b );
358 }
359 
361  const Vector& vs_rhs1, BLAS_Cpp::Transp trans_rhs2
362  , const Vector& vs_rhs3) const
363 {
364  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
365  return 0.0;
366 }
367 
369  const SpVectorSlice& sv_rhs1, BLAS_Cpp::Transp trans_rhs2
370  , const SpVectorSlice& sv_rhs3) const
371 {
372  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
373  return 0.0;
374 }
375 
377  BLAS_Cpp::Transp M_trans, value_type alpha
378  , const GenPermMatrixSlice& P1, BLAS_Cpp::Transp P1_trans
379  , const GenPermMatrixSlice& P2, BLAS_Cpp::Transp P2_trans
380  , value_type beta, MatrixSymOp* sym_lhs ) const
381 {
382  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
383 }
384 
385 // Level-3 BLAS
386 
389  ,BLAS_Cpp::Transp A_trans, const MatrixOp& B
390  ,BLAS_Cpp::Transp B_trans, value_type b) const
391 {
392  return false;
393 }
394 
396  MatrixOp* m_lhs, value_type alpha
397  ,const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1
398  ,BLAS_Cpp::Transp trans_rhs2, value_type beta ) const
399 {
400  return false;
401 }
402 
404  value_type alpha
405  ,const MatrixOp& mvw_rhs1, BLAS_Cpp::Transp trans_rhs1
406  ,const MatrixOp& mwo_rhs2,BLAS_Cpp::Transp trans_rhs2
407  ,value_type beta )
408 {
409  return false;
410 }
411 
413  BLAS_Cpp::Transp M_trans
414  ,value_type alpha
415  ,value_type beta
416  ,MatrixSymOp *sym_lhs
417  ) const
418 {
419  return false;
420 }
421 
423  const MatrixOp &mwo_rhs
424  ,BLAS_Cpp::Transp M_trans
425  ,value_type alpha
426  ,value_type beta
427  )
428 {
429  return false;
430 }
431 
432 } // end namespace AbstractLinAlgPack
433 
434 // Non-member functions
435 
436 // level-1 BLAS
437 
439 {
440  if(alpha == 0.0)
441  m_lhs->zero_out();
442  else if( alpha != 1.0 )
443  m_lhs->Mt_S(alpha);
444 }
445 
447  MatrixOp* mwo_lhs, value_type alpha, const MatrixOp& M_rhs
448  , BLAS_Cpp::Transp trans_rhs)
449 {
450  using BLAS_Cpp::no_trans;
451  using BLAS_Cpp::trans;
452 
453  // Give the rhs argument a chance to implement the operation
454  if(M_rhs.Mp_StM(mwo_lhs,alpha,trans_rhs))
455  return;
456 
457  // Give the lhs argument a change to implement the operation
458  if(mwo_lhs->Mp_StM(alpha,M_rhs,trans_rhs))
459  return;
460 
461  // We must try to implement the method
463  *m_mut_lhs = dynamic_cast<MultiVectorMutable*>(mwo_lhs);
465  !m_mut_lhs || !(m_mut_lhs->access_by() & MultiVector::COL_ACCESS)
467  ,"MatrixOp::Mp_StM(...) : Error, mwo_lhs of type \'"
468  << typeName(*mwo_lhs) << "\' could not implement the operation "
469  "and does not support the "
470  "\'MultiVectorMutable\' interface. Furthermore, "
471  "the rhs matix argument of type \'" << typeName(*mwo_lhs)
472  << "\' could not implement the operation!" );
473 
474 #ifdef TEUCHOS_DEBUG
476  !mwo_lhs->space_rows().is_compatible(
477  trans_rhs == no_trans ? M_rhs.space_rows() : M_rhs.space_cols() )
478  || !mwo_lhs->space_cols().is_compatible(
479  trans_rhs == no_trans ? M_rhs.space_cols() : M_rhs.space_rows() )
481  ,"MatrixOp::Mp_StM(mwo_lhs,...): Error, mwo_lhs of type \'"<<typeName(*mwo_lhs)<<"\' "
482  <<"is not compatible with M_rhs of type \'"<<typeName(M_rhs)<<"\'" );
483 #endif
484 
485  const size_type
486  rows = BLAS_Cpp::rows( mwo_lhs->rows(), mwo_lhs->cols(), trans_rhs ),
487  cols = BLAS_Cpp::cols( mwo_lhs->rows(), mwo_lhs->cols(), trans_rhs );
488  for( size_type j = 1; j <= cols; ++j )
489  AbstractLinAlgPack::Vp_StMtV( m_mut_lhs->col(j).get(), alpha, M_rhs, trans_rhs, EtaVector(j,cols)() );
490  // ToDo: consider row access?
491 }
492 
494  MatrixOp* mwo_lhs, value_type alpha
495  , const MatrixOp& M_rhs, BLAS_Cpp::Transp M_trans
496  , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
497  )
498 {
499 
500  // Give the rhs argument a chance to implement the operation
501  if(M_rhs.Mp_StMtP(mwo_lhs,alpha,M_trans,P_rhs,P_rhs_trans))
502  return;
503 
504  // Give the lhs argument a change to implement the operation
505  if(mwo_lhs->Mp_StMtP(alpha,M_rhs,M_trans,P_rhs,P_rhs_trans))
506  return;
507 
508  // We must try to implement the method
510  *m_mut_lhs = dynamic_cast<MultiVectorMutable*>(mwo_lhs);
513  ,"MatrixOp::Mp_StMtP(...) : Error, mwo_lhs of type \'"
514  << typeName(*mwo_lhs) << "\' does not support the "
515  "\'MultiVectorMutable\' interface!" );
516 
517  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
518 }
519 
521  MatrixOp* mwo_lhs, value_type alpha
522  , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
523  , const MatrixOp& M_rhs, BLAS_Cpp::Transp M_trans
524  )
525 {
526 
527  // Give the rhs argument a chance to implement the operation
528  if(M_rhs.Mp_StPtM(mwo_lhs,alpha,P_rhs,P_rhs_trans,M_trans))
529  return;
530 
531  // Give the lhs argument a change to implement the operation
532  if(mwo_lhs->Mp_StPtM(alpha,P_rhs,P_rhs_trans,M_rhs,M_trans))
533  return;
534 
535  // We must try to implement the method
537  *m_mut_lhs = dynamic_cast<MultiVectorMutable*>(mwo_lhs);
540  ,"MatrixOp::Mp_StPtM(...) : Error, mwo_lhs of type \'"
541  << typeName(*mwo_lhs) << "\' does not support the "
542  "\'MultiVectorMutable\' interface!" );
543 
544  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
545 
546 }
547 
549  MatrixOp* mwo_lhs, value_type alpha
550  , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
551  , const MatrixOp& M_rhs, BLAS_Cpp::Transp trans_rhs
552  , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
553  )
554 {
555 
556  // Give the rhs argument a chance to implement the operation
557  if(M_rhs.Mp_StPtMtP(mwo_lhs,alpha,P_rhs1,P_rhs1_trans,trans_rhs,P_rhs2,P_rhs2_trans))
558  return;
559 
560  // Give the lhs argument a change to implement the operation
561  if(mwo_lhs->Mp_StPtMtP(alpha,P_rhs1,P_rhs1_trans,M_rhs,trans_rhs,P_rhs2,P_rhs2_trans))
562  return;
563 
564  // We must try to implement the method
566  *m_mut_lhs = dynamic_cast<MultiVectorMutable*>(mwo_lhs);
569  ,"MatrixOp::Mp_StPtMtP(...) : Error, mwo_lhs of type \'"
570  << typeName(*mwo_lhs) << "\' does not support the "
571  "\'MultiVectorMutable\' interface!" );
572 
573  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
574 
575 }
576 
577 // level-3 blas
578 
581  ,const MatrixOp& A, BLAS_Cpp::Transp A_trans
582  ,const MatrixOp& B, BLAS_Cpp::Transp B_trans
583  ,value_type b
584  )
585 {
586 
587  // Give A a chance
588  if(A.Mp_StMtM(C,a,A_trans,B,B_trans,b))
589  return;
590  // Give B a chance
591  if(B.Mp_StMtM(C,a,A,A_trans,B_trans,b))
592  return;
593  // Give C a chance
594  if(C->Mp_StMtM(a,A,A_trans,B,B_trans,b))
595  return;
596 
597  //
598  // C = b*C + a*op(A)*op(B)
599  //
600  // We will perform this by column as:
601  //
602  // C(:,j) = b*C(:,j) + a*op(A)*op(B)*e(j), for j = 1...C.cols()
603  //
604  // by performing:
605  //
606  // t = op(B)*e(j)
607  // C(:,j) = b*C(:,j) + a*op(A)*t
608  //
609  Mp_MtM_assert_compatibility(C,BLAS_Cpp::no_trans,A,A_trans,B,B_trans);
610  MultiVectorMutable *Cmv = dynamic_cast<MultiVectorMutable*>(C);
612  !Cmv || !(Cmv->access_by() & MultiVector::COL_ACCESS)
614  ,"AbstractLinAlgPack::Mp_StMtM(...) : Error, mwo_lhs of type \'"
615  << typeName(*C) << "\' does not support the "
616  "\'MultiVectorMutable\' interface or does not support column access!" );
617  // ToDo: We could do this by row also!
619  t = ( B_trans == BLAS_Cpp::no_trans ? B.space_cols() : B.space_rows() ).create_member();
620  const index_type
621  C_rows = Cmv->rows(),
622  C_cols = Cmv->cols();
623  for( index_type j = 1; j <= C_cols; ++j ) {
624  // t = op(B)*e(j)
625  LinAlgOpPack::V_MtV( t.get(), B, B_trans, EtaVector(j,C_cols) );
626  // C(:,j) = a*op(A)*t + b*C(:,j)
627  Vp_StMtV( Cmv->col(j).get(), a, A, A_trans, *t, b );
628  }
629 }
630 
632  const MatrixOp &A
633  ,BLAS_Cpp::Transp A_trans
634  ,value_type a
635  ,value_type b
636  ,MatrixSymOp *B
637  )
638 {
639  // Give A a chance
640  if(A.syrk(A_trans,a,b,B))
641  return;
642  // Give B a chance
643  if(B->syrk(A,A_trans,a,b))
644  return;
645 
648  ,"AbstractLinAlgPack::syrk(...) : Error, neither the right-hand-side matrix "
649  "argument mwo_rhs of type \'" << typeName(A) << " nore the left-hand-side matrix "
650  "argument sym_lhs of type \'" << typeName(*B) << "\' could implement this operation!"
651  );
652 
653 }
virtual mat_ptr_t sub_view(const Range1D &row_rng, const Range1D &col_rng) const
Create a transient constant sub-matrix view of this matrix (if supported).
friend void syr2k(const MatrixOp &M, BLAS_Cpp::Transp M_trans, value_type alpha, const GenPermMatrixSlice &P1, BLAS_Cpp::Transp P1_trans, const GenPermMatrixSlice &P2, BLAS_Cpp::Transp P2_trans, value_type beta, MatrixSymOp *symwo_lhs)
virtual const VectorSpace & space_rows() const =0
Vector space for vectors that are compatible with the rows of the matrix.
COOMatrixPartitionedViewUtilityPack::TransposedPartition< T_Indice, T_Value > trans(COOMatrixPartitionedViewUtilityPack::Partition< T_Indice, T_Value > &part)
Create a transposed view of a partition object.
std::string typeName(const T &t)
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
void sign(const Vector &v, VectorMutable *z)
Compute the sign of each element in an input vector.
void Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta=1.0)
mwo_lhs = alpha * op(mwo_rhs1) * op(mwo_rhs2) + beta * mwo_lhs (right) (xGEMM).
virtual void zero_out()
M_lhs = 0 : Zero out the matrix.
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
virtual access_by_t access_by() const =0
Return a bit field for the types of access that are the most convenient.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
friend void Mt_S(MatrixOp *mwo_lhs, value_type alpha)
Aggregate matrix class for a matrix and its permuted view.
Index ubound() const
Return upper bound of the range.
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
const MatNorm calc_norm(EMatNormType requested_norm_type=MAT_NORM_1, bool allow_replacement=false) const
Compute a norm of this matrix.
The induced infinity norm ||M||inf, i.e. max abs row sum.
const LAPACK_C_Decl::f_int LAPACK_C_Decl::f_dbl_prec * A
T * get() const
virtual mat_ptr_t perm_view_update(const Permutation *P_row, const index_type row_part[], int num_row_part, const Permutation *P_col, const index_type col_part[], int num_col_part, const mat_ptr_t &perm_view) const
Reinitialize a permuted view: M_perm = P_row' * M * P_col.
RTOpPack::SparseSubVector sub_vec_view(const SpVectorSlice &sv, const Range1D &rng=Range1D())
Create an RTOpPack::SparseSubVector view object from a SpVectorSlice object.
virtual mat_mut_ptr_t clone()
Clone the non-const matrix object (if supported).
void V_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const V &V_rhs2)
v_lhs = alpha * op(M_rhs1) * V_rhs2.
friend value_type transVtMtV(const Vector &v_rhs1, const MatrixOp &M_rhs2, BLAS_Cpp::Transp trans_rhs2, const Vector &v_rhs3)
Transposed.
friend void Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans)
Interface adding operations specific for a symmetric matrix {abstract}.
virtual std::ostream & output(std::ostream &out) const
Virtual output function.
virtual bool syrk(BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs) const
Perform a rank-k update of a symmetric matrix of the form:
void Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans)
mwo_lhs += alpha * op(P_rhs1) * op(M_rhs) * op(P_rhs2).
Not transposed.
virtual size_type cols() const
Return the number of columns in the matrix.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
. One-based subregion index range class.
const f_int f_dbl_prec const f_int f_int const f_int f_int const f_dbl_prec f_int f_int f_dbl_prec w[]
Abstract interface for objects that represent a space for mutable coordinate vectors.
friend void Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta)
Standard subclass for representing a sub, possibly transposed, view of a matrix.
void syrk(const MatrixOp &mwo_rhs, BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs)
Perform a rank-k update of a symmetric matrix of the form:
void Mp_StMtP(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans)
mwo_lhs += alpha * op(M_rhs) * op(P_rhs).
std::ostream * out
const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_dbl_prec const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_int LAPACK_C_Decl::f_dbl_prec B[]
bool full_range() const
Returns true if the range represents the entire region (constructed from Range1D()) ...
void Mp_MtM_assert_compatibility(MatrixOp *m_lhs, BLAS_Cpp::Transp trans_lhs, const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &m_rhs2, BLAS_Cpp::Transp trans_rhs2)
op(m_lhs) += op(m_rhs1) * op(m_rhs2)
void Mp_StPtM(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans)
mwo_lhs += alpha * op(P) * op(M_rhs).
const LAPACK_C_Decl::f_int & M
Create an eta vector (scaled by alpha = default 1).
void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
v_lhs = alpha * op(M_rhs1) * v_rhs2 + beta * v_lhs (BLAS xGEMV)
const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_dbl_prec const LAPACK_C_Decl::f_int const LAPACK_C_Decl::f_dbl_prec LAPACK_C_Decl::f_dbl_prec * C
virtual bool is_compatible(const VectorSpace &vec_spc) const =0
Compare the compatibility of two vector spaces.
friend void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
Base class for all matrices that support basic matrix operations.
void Mt_S(MatrixOp *mwo_lhs, value_type alpha)
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
virtual index_type dim() const =0
Return the dimmension of the vector space.
The induced one norm ||M||1, i.e. max abs col sum.
Index lbound() const
Return lower bound of the range.
Interface for a collection of mutable vectors (multi-vector, matrix).
Abstract interface to permutation matrices.
friend void Mp_StMtP(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans)
void V_MtV(VectorMutable *v_lhs, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const V &V_rhs2)
v_lhs = op(M_rhs1) * V_rhs2.
virtual const VectorSpace & space_cols() const =0
Vector space for vectors that are compatible with the columns of the matrix.
Abstract interface for mutable coordinate vectors {abstract}.
void max_abs_ele(const Vector &v, value_type *max_v_j, index_type *max_j)
Compute the maximum element in a vector.
void Vp_MtV_assert_compatibility(VectorMutable *v_lhs, const MatrixOp &m_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
v_lhs += op(m_rhs1) * v_rhs2
virtual vec_mut_ptr_t create_member() const =0
Create a vector member from the vector space.
virtual size_type rows() const
Return the number of rows in the matrix.
virtual mat_ptr_t perm_view(const Permutation *P_row, const index_type row_part[], int num_row_part, const Permutation *P_col, const index_type col_part[], int num_col_part) const
Create a permuted view: M_perm = P_row' * M * P_col.
virtual vec_mut_ptr_t col(index_type j)=0
Get a mutable column vector.
friend void syrk(const MatrixOp &mwo_rhs, BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs)
friend void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta)
Transp
TRANS.
int n
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
size_type nz() const
Return the number of non-zero elements.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void V_MtV(DVector &v_lhs, const T_Matrix &gm_rhs1, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2)
v_lhs = T_M * vs_lhs (templated matrix type T_M)
Concrete matrix type to represent general permutation (mapping) matrices.
friend void Mp_StPtM(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp M_trans)
virtual MatrixOp & operator=(const MatrixOp &mwo_rhs)
M_lhs = mwo_rhs : Virtual assignment operator.
friend void Vp_StPtMtV(VectorMutable *v_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs2, BLAS_Cpp::Transp M_rhs2_trans, const Vector &v_rhs3, value_type beta)