AbstractLinAlgPack_ConvertToCSC.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef CONVERT_TO_SPARSE_COMPRESSED_COLUMN_H
00030 #define CONVERT_TO_SPARSE_COMPRESSED_COLUMN_H
00031 
00032 #include "AbstractLinAlgPack_Types.hpp"
00033 #include "DenseLinAlgPack_IVector.hpp"
00034 
00078 
00079 namespace AbstractLinAlgPack {
00080 
00085 class ConvertToCSC {
00086 public:
00087 
00089   virtual ~ConvertToCSC()
00090   {}
00091 
00097   virtual size_type num_in_column(
00098       BLAS_Cpp::Transp          trans
00099     , size_type             col_offset
00100     , const IVector::value_type*    col_perm
00101     , size_type*            num_in_col  ) const = 0;
00102     
00105   virtual void insert_nonzeros(
00106       BLAS_Cpp::Transp          trans
00107     , value_type            alpha
00108     , size_type             row_offset
00109     , size_type             col_offset
00110     , const IVector::value_type*    row_perm
00111     , const IVector::value_type*    col_perm
00112     , size_type*            next_nz_in_col
00113     , FortranTypes::f_dbl_prec*     D_val
00114     , FortranTypes::f_int*        D_row_i     ) const = 0;
00115 
00119   virtual value_type insert_scaled_nonzeros(
00120       BLAS_Cpp::Transp          trans
00121     , value_type            scaled_max_ele
00122     , size_type             row_offset
00123     , size_type             col_offset
00124     , const IVector::value_type*    row_perm
00125     , const IVector::value_type*    col_perm
00126     , size_type*            next_nz_in_col
00127     , FortranTypes::f_dbl_prec*     D_val
00128     , FortranTypes::f_int*        D_row_i     ) const = 0;
00129 
00130 };  // end class ConvertToCSC
00131 
00132 namespace ConvertToSparseCompressedColumnPack {
00133 
00137 
00140 inline void scalar_insert_nonzero(
00141     value_type            alpha
00142   , size_type             row_i
00143   , size_type             col_j
00144   , size_type*            next_nz_in_col
00145   , FortranTypes::f_dbl_prec*     D_val
00146   , FortranTypes::f_int*        D_row_i     )
00147 {
00148   size_type ele = next_nz_in_col[ col_j - 1 ]++;
00149   D_val[ ele - 1 ] = alpha;
00150   if( D_row_i )
00151     D_row_i[ ele - 1 ] = row_i;
00152 }
00153 
00156 void vector_insert_nonzeros(
00157     const DVectorSlice&       vs
00158   , value_type            alpha
00159   , size_type             row_offset
00160   , size_type             col_j
00161   , const IVector::value_type*    row_perm
00162   , size_type*            next_nz_in_col
00163   , FortranTypes::f_dbl_prec*     D_val
00164   , FortranTypes::f_int*        D_row_i     );
00165 
00168 size_type dense_num_in_column(
00169     size_type             rows
00170   , size_type             cols
00171   , BLAS_Cpp::Transp          trans
00172   , size_type             col_offset
00173   , const IVector::value_type*    col_perm
00174   , size_type*            num_in_col  );
00175 
00178 void dense_insert_nonzeros(
00179     const DMatrixSlice&       gms
00180   , BLAS_Cpp::Transp          trans
00181   , value_type            alpha
00182   , size_type             row_offset
00183   , size_type             col_offset
00184   , const IVector::value_type*    row_perm
00185   , const IVector::value_type*    col_perm
00186   , size_type*            next_nz_in_col
00187   , FortranTypes::f_dbl_prec*     D_val
00188   , FortranTypes::f_int*        D_row_i     );
00189 
00192 value_type dense_insert_scaled_nonzeros(
00193     const DMatrixSlice&       gms
00194   , BLAS_Cpp::Transp          trans
00195   , value_type            scaled_max_ele
00196   , size_type             row_offset
00197   , size_type             col_offset
00198   , const IVector::value_type*    row_perm
00199   , const IVector::value_type*    col_perm
00200   , size_type*            next_nz_in_col
00201   , FortranTypes::f_dbl_prec*     D_val
00202   , FortranTypes::f_int*        D_row_i     );
00203 
00208 
00210 size_type num_in_column(
00211     const MatrixOp&       m
00212   , BLAS_Cpp::Transp          trans
00213   , size_type             col_offset
00214   , const IVector::value_type*    col_perm
00215   , size_type*            num_in_col  );
00216 
00218 void insert_nonzeros(
00219     const MatrixOp&       m
00220   , BLAS_Cpp::Transp          trans
00221   , value_type            alpha
00222   , size_type             row_offset
00223   , size_type             col_offset
00224   , const IVector::value_type*    row_perm
00225   , const IVector::value_type*    col_perm
00226   , size_type*            next_nz_in_col
00227   , FortranTypes::f_dbl_prec*     D_val
00228   , FortranTypes::f_int*        D_row_i     );
00229 
00231 value_type insert_scaled_nonzeros(
00232     const MatrixOp&       m
00233   , BLAS_Cpp::Transp          trans
00234   , value_type            scaled_max_ele
00235   , size_type             row_offset
00236   , size_type             col_offset
00237   , const IVector::value_type*    row_perm
00238   , const IVector::value_type*    col_perm
00239   , size_type*            next_nz_in_col
00240   , FortranTypes::f_dbl_prec*     D_val
00241   , FortranTypes::f_int*        D_row_i     );
00242 
00244 
00246 
00247 } // end namespace ConvertToSparseCompressedColumnPack
00248 
00249 } // end namespace AbstractLinAlgPack
00250 
00251 //  end Conversion utilities
00253 
00254 // /////////////////////////////////////////////////////////////////
00255 // Inline definitions
00256 
00257 #endif  // CONVERT_TO_SPARSE_COMPRESSED_COLUMN_H

Generated on Thu Sep 18 12:33:50 2008 for AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects by doxygen 1.3.9.1