fn_polyfit.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_polyfit
  16. //! @{
  17. template<typename T1, typename T2>
  18. inline
  19. typename
  20. enable_if2
  21. <
  22. is_supported_blas_type<typename T1::elem_type>::value,
  23. bool
  24. >::result
  25. polyfit(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type, T1>& X, const Base<typename T1::elem_type, T2>& Y, const uword N)
  26. {
  27. arma_extra_debug_sigprint();
  28. const bool status = glue_polyfit::apply_direct(out, X.get_ref(), Y.get_ref(), N);
  29. if(status == false)
  30. {
  31. out.soft_reset();
  32. arma_debug_warn("polyfit(): failed");
  33. }
  34. return status;
  35. }
  36. template<typename T1, typename T2>
  37. arma_warn_unused
  38. inline
  39. typename
  40. enable_if2
  41. <
  42. is_supported_blas_type<typename T1::elem_type>::value,
  43. const Glue<T1, T2, glue_polyfit>
  44. >::result
  45. polyfit(const Base<typename T1::elem_type, T1>& X, const Base<typename T1::elem_type, T2>& Y, const uword N)
  46. {
  47. arma_extra_debug_sigprint();
  48. return Glue<T1, T2, glue_polyfit>(X.get_ref(), Y.get_ref(), N);
  49. }
  50. //! @}