harwell_boeing.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  12. #include <Eigen/Sparse>
  13. #include <vector>
  14. namespace igl
  15. {
  16. // Convert the matrix to Compressed sparse column (CSC or CCS) format,
  17. // also known as Harwell Boeing format. As described:
  18. // http://netlib.org/linalg/html_templates/node92.html
  19. // or
  20. // http://en.wikipedia.org/wiki/Sparse_matrix
  21. // #Compressed_sparse_column_.28CSC_or_CCS.29
  22. // Templates:
  23. // Scalar type of sparse matrix like double
  24. // Inputs:
  25. // A sparse m by n matrix
  26. // Outputs:
  27. // num_rows number of rows
  28. // V non-zero values, row indices running fastest, size(V) = nnz
  29. // R row indices corresponding to vals, size(R) = nnz
  30. // C index in vals of first entry in each column, size(C) = num_cols+1
  31. //
  32. // All indices and pointers are 0-based
  33. template <typename Scalar, typename Index>
  34. IGL_INLINE void harwell_boeing(
  35. const Eigen::SparseMatrix<Scalar> & A,
  36. int & num_rows,
  37. std::vector<Scalar> & V,
  38. std::vector<Index> & R,
  39. std::vector<Index> & C);
  40. }
  41. #ifdef IGL_HEADER_ONLY
  42. # include "harwell_boeing.cpp"
  43. #endif
  44. #endif