SpToDOp_bones.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 SpToDOp
  16. //! @{
  17. //! Class for storing data required for delayed unary operations on a sparse
  18. //! matrix that produce a dense matrix; the data for storage may include
  19. //! the operand (e.g. the matrix to which the operation is to be applied) and the unary operator (e.g. inverse).
  20. //! The operand is stored as a reference (which can be optimised away),
  21. //! while the operator is "stored" through the template definition (op_type).
  22. //! The operands can be 'SpMat', 'SpRow', 'SpCol', 'SpOp', and 'SpGlue'.
  23. //! Note that as 'SpGlue' can be one of the operands, more than one matrix can be stored.
  24. //!
  25. //! For example, we could have:
  26. //! SpToDOp< SpGlue< SpMat, SpMat, sp_glue_times >, op_sp_plus >
  27. template<typename T1, typename op_type>
  28. class SpToDOp : public Base<typename T1::elem_type, SpToDOp<T1, op_type> >
  29. {
  30. public:
  31. typedef typename T1::elem_type elem_type;
  32. typedef typename get_pod_type<elem_type>::result pod_type;
  33. inline explicit SpToDOp(const T1& in_m);
  34. inline SpToDOp(const T1& in_m, const elem_type in_aux);
  35. inline ~SpToDOp();
  36. arma_aligned const T1& m; //!< the operand; must be derived from SpBase
  37. arma_aligned elem_type aux; //!< auxiliary data, using the element type as used by T1
  38. static const bool is_row = op_type::template traits<T1>::is_row;
  39. static const bool is_col = op_type::template traits<T1>::is_col;
  40. static const bool is_xvec = op_type::template traits<T1>::is_xvec;
  41. };
  42. //! @}