harwell_boeing.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #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. // Templates:
  22. // Scalar type of sparse matrix like double
  23. // Inputs:
  24. // A sparse m by n matrix
  25. // Outputs:
  26. // num_rows number of rows
  27. // V non-zero values, row indices running fastest, size(V) = nnz
  28. // R row indices corresponding to vals, size(R) = nnz
  29. // C index in vals of first entry in each column, size(C) = num_cols+1
  30. //
  31. // All indices and pointers are 0-based
  32. template <typename Scalar, typename Index>
  33. IGL_INLINE void harwell_boeing(
  34. const Eigen::SparseMatrix<Scalar> & A,
  35. int & num_rows,
  36. std::vector<Scalar> & V,
  37. std::vector<Index> & R,
  38. std::vector<Index> & C);
  39. }
  40. #ifndef IGL_STATIC_LIBRARY
  41. # include "harwell_boeing.cpp"
  42. #endif
  43. #endif