MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / SparseMatrixBase

Class SparseMatrixBase

extensions/include/cuMat/src/SparseMatrixBase.h:360–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358 */
359template<typename _Derived>
360class SparseMatrixBase : public MatrixBase<_Derived>
361{
362public:
363 typedef _Derived Type;
364 typedef MatrixBase<_Derived> Base;
365 CUMAT_PUBLIC_API
366 enum
367 {
368 /**
369 * \brief Sparsity pattern
370 */
371 SFlags = internal::traits<_Derived>::SFlags
372 };
373
374 /**
375 * \brief The type of the storage indices.
376 * This is fixed to an integer and not using Index, because this is faster for CUDA.
377 */
378 using StorageIndex = typename SparsityPattern<SFlags>::StorageIndex;
379
380protected:
381 SparsityPattern<SFlags> sparsity_;
382 /**
383 * \brief Number of batches.
384 */
385 Index batches_;
386
387public:
388 SparseMatrixBase()
389 : batches_(0)
390 {}
391
392 SparseMatrixBase(const SparsityPattern<SFlags>& sparsityPattern, Index batches)
393 : sparsity_(sparsityPattern)
394 , batches_(batches)
395 {
396 sparsityPattern.assertValid();
397 CUMAT_ASSERT(CUMAT_IMPLIES(Batches == Dynamic, Batches == batches) &&
398 "compile-time batch count specified, but does not match runtime batch count");
399 }
400
401 /**
402 * \brief Returns the sparsity pattern of this matrix.
403 * This can be used to create another matrix with the same sparsity pattern.
404 * \return The sparsity pattern of this matrix.
405 */
406 __host__ __device__ CUMAT_STRONG_INLINE const SparsityPattern<SFlags>& getSparsityPattern() const
407 {
408 return sparsity_;
409 }
410
411 /**
412 * \brief Checks if this matrix is initialized with a sparsity pattern and can therefore be used in expressions.
413 */
414 bool isInitialized() const
415 {
416 return sparsity_.rows > 0 && sparsity_.cols > 0 && batches_ > 0;
417 }

Callers

nothing calls this directly

Calls 1

getSparseCoeffMethod · 0.80

Tested by

no test coverage detected