fn_trimat.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup fn_trimat
  16. //! @{
  17. template<typename T1>
  18. arma_warn_unused
  19. arma_inline
  20. const Op<T1, op_trimat>
  21. trimatu(const Base<typename T1::elem_type,T1>& X)
  22. {
  23. arma_extra_debug_sigprint();
  24. return Op<T1, op_trimat>(X.get_ref(), 0, 0);
  25. }
  26. template<typename T1>
  27. arma_warn_unused
  28. arma_inline
  29. const Op<T1, op_trimat>
  30. trimatl(const Base<typename T1::elem_type,T1>& X)
  31. {
  32. arma_extra_debug_sigprint();
  33. return Op<T1, op_trimat>(X.get_ref(), 1, 0);
  34. }
  35. template<typename T1>
  36. arma_warn_unused
  37. arma_inline
  38. const SpOp<T1, spop_trimat>
  39. trimatu(const SpBase<typename T1::elem_type,T1>& X)
  40. {
  41. arma_extra_debug_sigprint();
  42. return SpOp<T1, spop_trimat>(X.get_ref(), 0, 0);
  43. }
  44. template<typename T1>
  45. arma_warn_unused
  46. arma_inline
  47. const SpOp<T1, spop_trimat>
  48. trimatl(const SpBase<typename T1::elem_type,T1>& X)
  49. {
  50. arma_extra_debug_sigprint();
  51. return SpOp<T1, spop_trimat>(X.get_ref(), 1, 0);
  52. }
  53. //
  54. template<typename T1>
  55. arma_warn_unused
  56. arma_inline
  57. const Op<T1, op_trimatl_ext>
  58. trimatl(const Base<typename T1::elem_type,T1>& X, const sword k)
  59. {
  60. arma_extra_debug_sigprint();
  61. const uword row_offset = (k < 0) ? uword(-k) : uword(0);
  62. const uword col_offset = (k > 0) ? uword( k) : uword(0);
  63. return Op<T1, op_trimatl_ext>(X.get_ref(), row_offset, col_offset);
  64. }
  65. template<typename T1>
  66. arma_warn_unused
  67. arma_inline
  68. const Op<T1, op_trimatu_ext>
  69. trimatu(const Base<typename T1::elem_type,T1>& X, const sword k)
  70. {
  71. arma_extra_debug_sigprint();
  72. const uword row_offset = (k < 0) ? uword(-k) : uword(0);
  73. const uword col_offset = (k > 0) ? uword( k) : uword(0);
  74. return Op<T1, op_trimatu_ext>(X.get_ref(), row_offset, col_offset);
  75. }
  76. // // TODO: implement for sparse matrices
  77. // template<typename T1>
  78. // arma_warn_unused
  79. // arma_inline
  80. // const SpOp<T1, spop_trimatu_ext>
  81. // trimatu(const SpBase<typename T1::elem_type,T1>& X, const sword k)
  82. // {
  83. // arma_extra_debug_sigprint();
  84. //
  85. // const uword row_offset = (k < 0) ? uword(-k) : uword(0);
  86. // const uword col_offset = (k > 0) ? uword( k) : uword(0);
  87. //
  88. // return SpOp<T1, spop_trimatu_ext>(X.get_ref(), row_offset, col_offset);
  89. // }
  90. //
  91. //
  92. //
  93. // // TODO: implement for sparse matrices
  94. // template<typename T1>
  95. // arma_warn_unused
  96. // arma_inline
  97. // const SpOp<T1, spop_trimatl_ext>
  98. // trimatl(const SpBase<typename T1::elem_type,T1>& X, const sword k)
  99. // {
  100. // arma_extra_debug_sigprint();
  101. //
  102. // const uword row_offset = (k < 0) ? uword(-k) : uword(0);
  103. // const uword col_offset = (k > 0) ? uword( k) : uword(0);
  104. //
  105. // return SpOp<T1, spop_trimatl_ext>(X.get_ref(), row_offset, col_offset);
  106. // }
  107. //! @}