Chris@49: // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2008-2012 Conrad Sanderson Chris@49: // Chris@49: // This Source Code Form is subject to the terms of the Mozilla Public Chris@49: // License, v. 2.0. If a copy of the MPL was not distributed with this Chris@49: // file, You can obtain one at http://mozilla.org/MPL/2.0/. Chris@49: Chris@49: Chris@49: //! \addtogroup fn_max Chris@49: //! @{ Chris@49: Chris@49: Chris@49: //! \brief Chris@49: //! Delayed 'maximum values' operation. Chris@49: //! The dimension, along which the maxima are found, is set via 'dim'. Chris@49: //! For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). Chris@49: //! For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). Chris@49: //! The default is dim = 0. Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: const Op Chris@49: max Chris@49: ( Chris@49: const T1& X, Chris@49: const uword dim = 0, Chris@49: const typename enable_if< is_arma_type::value == true >::result* junk1 = 0, Chris@49: const typename enable_if< resolves_to_vector::value == false >::result* junk2 = 0 Chris@49: ) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_ignore(junk1); Chris@49: arma_ignore(junk2); Chris@49: Chris@49: return Op(X, dim, 0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: const Op Chris@49: max Chris@49: ( Chris@49: const T1& X, Chris@49: const uword dim, Chris@49: const typename enable_if::value == true>::result* junk = 0 Chris@49: ) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_ignore(junk); Chris@49: Chris@49: return Op(X, dim, 0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: inline Chris@49: arma_warn_unused Chris@49: typename T1::elem_type Chris@49: max Chris@49: ( Chris@49: const T1& X, Chris@49: const arma_empty_class junk1 = arma_empty_class(), Chris@49: const typename enable_if::value == true>::result* junk2 = 0 Chris@49: ) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_ignore(junk1); Chris@49: arma_ignore(junk2); Chris@49: Chris@49: return op_max::max(X); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! \brief Chris@49: //! Immediate 'find maximum value' operation, Chris@49: //! invoked, for example, by: max(max(A)) Chris@49: template Chris@49: inline Chris@49: arma_warn_unused Chris@49: typename T1::elem_type Chris@49: max(const Op& in) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_extra_debug_print("max(): two consecutive max() calls detected"); Chris@49: Chris@49: return op_max::max(in.m); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: const Op< Op, op_max> Chris@49: max(const Op& in, const uword dim) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: return Op< Op, op_max>(in, dim, 0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: arma_warn_unused Chris@49: const typename arma_scalar_only::result & Chris@49: max(const T& x) Chris@49: { Chris@49: return x; Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: inline Chris@49: arma_warn_unused Chris@49: typename Chris@49: enable_if2 Chris@49: < Chris@49: (is_arma_sparse_type::value == true) && (resolves_to_sparse_vector::value == true), Chris@49: typename T1::elem_type Chris@49: >::result Chris@49: max(const T1& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: return spop_max::vector_max(x); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: inline Chris@49: typename Chris@49: enable_if2 Chris@49: < Chris@49: (is_arma_sparse_type::value == true) && (resolves_to_sparse_vector::value == false), Chris@49: const SpOp Chris@49: >::result Chris@49: max(const T1& X, const uword dim = 0) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: return SpOp(X, dim, 0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: inline Chris@49: arma_warn_unused Chris@49: typename T1::elem_type Chris@49: max(const SpOp& X) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_extra_debug_print("max(): two consecutive max() calls detected"); Chris@49: Chris@49: return spop_max::vector_max(X.m); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: inline Chris@49: const SpOp< SpOp, spop_max> Chris@49: max(const SpOp& in, const uword dim) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: return SpOp< SpOp, spop_max>(in, dim, 0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! @}