harwell_boeing.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_HARWELL_BOEING_H
  9. #define IGL_HARWELL_BOEING_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Sparse>
  12. #include <vector>
  13. namespace igl
  14. {
  15. /// Convert the matrix to Compressed sparse column (CSC or CCS) format,
  16. /// also known as Harwell Boeing format. As described:
  17. /// http://netlib.org/linalg/html_templates/node92.html
  18. /// or
  19. /// http://en.wikipedia.org/wiki/Sparse_matrix
  20. /// #Compressed_sparse_column_.28CSC_or_CCS.29
  21. /// @tparam Scalar type of sparse matrix like double
  22. /// @param[in] A sparse m by n matrix
  23. /// @param[out] num_rows number of rows
  24. /// @param[out] V non-zero values, row indices running fastest, size(V) = nnz
  25. /// @param[out] R row indices corresponding to vals, size(R) = nnz
  26. /// @param[out] C index in vals of first entry in each column, size(C) = num_cols+1
  27. ///
  28. /// \note All indices and pointers are 0-based
  29. template <typename Scalar, typename Index>
  30. IGL_INLINE void harwell_boeing(
  31. const Eigen::SparseMatrix<Scalar> & A,
  32. int & num_rows,
  33. std::vector<Scalar> & V,
  34. std::vector<Index> & R,
  35. std::vector<Index> & C);
  36. }
  37. #ifndef IGL_STATIC_LIBRARY
  38. # include "harwell_boeing.cpp"
  39. #endif
  40. #endif