/usr/include/trilinos/AbstractLinAlgPack_MatrixSparseCOORSerial.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
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 | // @HEADER
// ***********************************************************************
//
// Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
// Copyright (2003) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
//
// ***********************************************************************
// @HEADER
#ifndef MATRIX_SPARSE_COOR_SERIAL_H
#define MATRIX_SPARSE_COOR_SERIAL_H
#include "AbstractLinAlgPack_MatrixOp.hpp"
#include "AbstractLinAlgPack_VectorSpaceSerial.hpp"
#include "AbstractLinAlgPack_MatrixLoadSparseElements.hpp"
#include "AbstractLinAlgPack_MatrixExtractSparseElements.hpp"
#include "ReleaseResource.hpp"
namespace AbstractLinAlgPack {
/** \brief Coordinate matrix subclass.
*
* ToDo: Finish documentation!
*/
class MatrixSparseCOORSerial
: virtual public AbstractLinAlgPack::MatrixOp
, virtual public MatrixLoadSparseElements
, virtual public MatrixExtractSparseElements
{
public:
/** @name Public types */
//@{
/** \brief . */
typedef Teuchos::RCP<
MemMngPack::ReleaseResource> release_resource_ptr_t;
/** \brief Subclass to delete dynamically allocated memory with \c delete[].
*
* This subclass can be used by the client to cause
*/
class ReleaseValRowColArrays
: public MemMngPack::ReleaseResource
{
public:
/// Gives pointers to buffers to delete[]
ReleaseValRowColArrays(
value_type *val
,index_type *row_i
,index_type *col_j
)
:val_(val)
,row_i_(row_i)
,col_j_(col_j)
,owns_mem_(true)
{}
// Calls delete on buffers if <tt>this->owns_memory() == true</tt>
~ReleaseValRowColArrays();
/// Overridden from ReleaseResource
bool resource_is_bound() const;
/// Release ownership of memory
void release_ownership() { owns_mem_ = false; }
value_type* val() { return val_; }
index_type* row_i() { return row_i_; }
index_type* col_j() { return col_j_; }
private:
value_type *val_;
index_type *row_i_;
index_type *col_j_;
bool owns_mem_;
// not defined and not to be called
ReleaseValRowColArrays();
ReleaseValRowColArrays(const ReleaseValRowColArrays&);
ReleaseValRowColArrays& operator=(const ReleaseValRowColArrays&);
}; // end class ReleaseValRowColArrays
//@}
/** @name Constructors / initializers */
//@{
/** \brief Let \c this allocate its own memory.
*/
MatrixSparseCOORSerial();
/** \brief Give memory to use to store nonzero elements.
*
* @param max_nz [in] Size of the buffers \c val[], \c row_i[] and \c col_j[]. It is allowed for
* <tt>max_nz == 0</tt> in which case this matrix will not have any nonzero elements
* (i.e. the zero matrix).
* @param val [in] Buffer to store the nonzero entry values. On input <tt>val[k], for k = 0...nz-1</tt>
* must be set to valid nonzero entry values if <tt>rows > 0 && nz > 0</tt>.
* @param row_i [in] Buffer to store the nonzero entry row indexes. On input <tt>row_i[k], for k = 0...nz-1</tt>
* must be set to valid nonzero entry row indexes if <tt>rows > 0 && nz > 0</tt>.
* @param col_j [in] Buffer to store the nonzero entry row indexes. On input <tt>col_j[k], for k = 0...nz-1</tt>
* must be set to valid nonzero entry row indexes if <tt>rows > 0 && nz > 0</tt>.
* @param release_resource
* [in] Smart pointer to a <tt>MemMngPack::ReleaseResouce</tt> object that will
* deallocate the memory for the buffers \c val[], \c row_i[] and \c col_j[] when \c this
* is finished with them. It is allowed for <tt>release_resource.get() == NULL</tt> in which
* case the client will be responsible to free this memory. The client can use the
* subclass \c ReleaseValRowColArrays to allow \c this to delete memory created with
* \c new[] by setting <tt>release_resource = Teuchos::rcp(
* new ReleaseValRowColArrays(val,row_i,col_j) )</tt> where \c val, \c row_i and \c col_j
* where allocated with \c new[]. The \c release_resource object represents the sharing
* of the data \c val[], \c row_i[] and \c col_j[].
* @param rows [in] Number of rows in the matrix. Default = 0 for fully uninitialized.
* @param cols [in] Number of columns in the matrix. Ignored if <tt>rows == 0</tt>.
* @param nz [in] Number of nonzero elements in \c val[], \c row_i[] and \c col_j[]
* already set. Setting a value of <tt>nz > 0</tt> allows the client
* to setup a matrix object with nonzero elements ready to go. Ignored
* if <tt>rows == 0</tt>.
* @param check_input
* [in] If \c true and <tt>rows > 0 && nz > 0</tt> then the row and colunmn
* indexes in \c row_i[] and \c col_j[] will be checked! The defualt is \c false.
*
* Preconditions:<ul>
* <li> <tt>max_nz > 0</tt> (throw <tt>std::invalid_argument</tt>)
* <li> <tt>val != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> <tt>row_i != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> <tt>col_j != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> <tt>rows >= 0</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>rows > 0</tt>] <tt>cols > 0</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>rows > 0</tt>] <tt>0 <= nz <= max_nz</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>nz > 0</tt>] <tt>1 <= row_i[k] <= rows, for k = 0...nz-1</tt> (throw std::invalid_argument)
* <li> [<tt>nz > 0</tt>] <tt>1 <= col_j[k] <= cols, for k = 0...nz-1</tt> (throw std::invalid_argument)
* </ul>
*
* Postconditions:<ul>
* <li> <tt>this->release_resource().get() == release_resource</tt>
* <li> [<tt>rows > 0</tt>] <tt>this->rows() == rows</tt>
* <li> [<tt>rows > 0</tt>] <tt>this->cols() == cols</tt>
* <li> [<tt>rows > 0</tt>] <tt>this->nz() == nz</tt>
* </ul>
*/
void set_buffers(
size_type max_nz
,value_type *val
,index_type *row_i
,index_type *col_j
,const release_resource_ptr_t &release_resource
,size_type rows = 0
,size_type cols = 0
,size_type nz = 0
,bool check_input = false
);
/** \brief Release all owned memory and make uninitialized.
*
* Postconditions:<ul>
* <li> On the next call to <tt>this->reinitialize(rows,cols,max_nz)</tt>
* \c this will allocate its own memory.
* <li>
* </ul>
*/
void set_uninitialized();
//@}
/** @name Access */
//@{
/** \brief . */
value_type* val();
/** \brief . */
const value_type* val() const;
/** \brief . */
index_type* row_i();
/** \brief . */
const index_type* row_i() const;
/** \brief . */
index_type* col_j();
/** \brief . */
const index_type* col_j() const;
/** \brief . */
const release_resource_ptr_t& release_resource() const;
//@}
/** @name Overridden from MatrixBase */
//@{
/** \brief . */
size_type rows() const;
/** \brief . */
size_type cols() const;
/** \brief . */
size_type nz() const;
//@}
/** @name Overridden from MatrixOp */
//@{
/** \brief . */
const VectorSpace& space_cols() const;
/** \brief . */
const VectorSpace& space_rows() const;
/** \brief . */
MatrixOp& operator=(const MatrixOp& M);
/** \brief . */
std::ostream& output(std::ostream& out) const;
/** \brief . */
void Vp_StMtV(
VectorMutable* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
, const Vector& v_rhs2, value_type beta) const;
// ToDo: Add more method overrides as they are needed!
//@}
/** @name Overridden from MatrixLoadSparseElements */
//@{
/** \brief . */
void reinitialize(
size_type rows
,size_type cols
,size_type max_nz
,EAssumeElementUniqueness element_uniqueness
);
void reset_to_load_values();
/** \brief . */
void get_load_nonzeros_buffers(
size_type max_nz_load
,value_type **val
,index_type **row_i
,index_type **col_j
);
/** \brief . */
void commit_load_nonzeros_buffers(
size_type nz_commit
,value_type **val
,index_type **row_i
,index_type **col_j
);
/** \brief . */
void finish_construction( bool test_setup );
//@}
/** @name Overridden from MatrixExtractSparseElements */
//@{
/** \brief . */
index_type count_nonzeros(
EElementUniqueness element_uniqueness
,const index_type inv_row_perm[]
,const index_type inv_col_perm[]
,const Range1D &row_rng
,const Range1D &col_rng
,index_type dl
,index_type du
) const;
/** \brief . */
void coor_extract_nonzeros(
EElementUniqueness element_uniqueness
,const index_type inv_row_perm[]
,const index_type inv_col_perm[]
,const Range1D &row_rng
,const Range1D &col_rng
,index_type dl
,index_type du
,value_type alpha
,const index_type len_Aval
,value_type Aval[]
,const index_type len_Aij
,index_type Arow[]
,index_type Acol[]
,const index_type row_offset
,const index_type col_offset
) const;
//@}
private:
// //////////////////////////////
// Private types
// //////////////////////////////
// Public types
size_type rows_;
size_type cols_;
size_type max_nz_;
EAssumeElementUniqueness element_uniqueness_;
size_type nz_;
value_type *val_;
index_type *row_i_;
index_type *col_j_;
release_resource_ptr_t release_resource_;
bool self_allocate_; // True if this allocates the memory
VectorSpaceSerial space_cols_;
VectorSpaceSerial space_rows_;
size_type max_nz_load_; // cashed
bool reload_val_only_; // cashed
size_type reload_val_only_nz_last_; // cashed
// //////////////////////////////
// Private member functions
void make_storage_unique();
// static
static release_resource_ptr_t release_resource_null_;
}; // end class MatrixSparseCOORSerial
// //////////////////////////////////
// Inline members
inline
value_type* MatrixSparseCOORSerial::val()
{
make_storage_unique();
return val_;
}
inline
const value_type* MatrixSparseCOORSerial::val() const
{
return val_;
}
inline
index_type* MatrixSparseCOORSerial::row_i()
{
make_storage_unique();
return row_i_;
}
inline
const index_type* MatrixSparseCOORSerial::row_i() const
{
return row_i_;
}
inline
index_type* MatrixSparseCOORSerial::col_j()
{
make_storage_unique();
return col_j_;
}
inline
const index_type* MatrixSparseCOORSerial::col_j() const
{
return col_j_;
}
inline
const MatrixSparseCOORSerial::release_resource_ptr_t&
MatrixSparseCOORSerial::release_resource() const
{
return self_allocate_ ? release_resource_null_ : release_resource_;
}
} // end namespace AbstractLinAlgPack
#endif // MATRIX_SPARSE_COOR_SERIAL_H
|