max@0: // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2008-2011 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup fn_max max@0: //! @{ max@0: max@0: max@0: //! \brief max@0: //! Delayed 'maximum values' operation. max@0: //! The dimension, along which the maxima are found, is set via 'dim'. max@0: //! For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). max@0: //! For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). max@0: //! The default is dim = 0. max@0: max@0: template max@0: arma_inline max@0: const Op max@0: max(const Base& X, const uword dim = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return Op(X.get_ref(), dim, 0); max@0: } max@0: max@0: max@0: //! Immediate 'find the maximum value in a row vector' operation max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const Row& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: const uword A_n_elem = A.n_elem; max@0: max@0: arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(A.mem, A_n_elem); max@0: } max@0: max@0: max@0: max@0: //! Immediate 'find the maximum value in a column vector' operation max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const Col& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: const uword A_n_elem = A.n_elem; max@0: max@0: arma_debug_check( (A_n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(A.mem, A_n_elem); max@0: } max@0: max@0: max@0: max@0: //! \brief max@0: //! Immediate 'find maximum value' operation, max@0: //! invoked, for example, by: max(max(A)) max@0: template max@0: inline max@0: arma_warn_unused max@0: typename T1::elem_type max@0: max(const Op& in) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_extra_debug_print("max(): two consecutive max() calls detected"); max@0: max@0: typedef typename T1::elem_type eT; max@0: max@0: const unwrap tmp1(in.m); max@0: const Mat& X = tmp1.M; max@0: max@0: const uword X_n_elem = X.n_elem; max@0: max@0: arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(X.mem, X_n_elem); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: const Op< Op, op_max> max@0: max(const Op& in, const uword dim) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return Op< Op, op_max>(in, dim, 0); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const subview_row& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(A); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const subview_col& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(A.colptr(0), A.n_rows); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const Op, op_max>& in) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_extra_debug_print("max(): two consecutive max() calls detected"); max@0: max@0: const subview& X = in.m; max@0: max@0: arma_debug_check( (X.n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(X); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const diagview& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(A); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: max(const subview_elem1& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: const Mat X(A); max@0: max@0: const uword X_n_elem = X.n_elem; max@0: max@0: arma_debug_check( (X_n_elem == 0), "max(): given object has no elements" ); max@0: max@0: return op_max::direct_max(X.mem, X_n_elem); max@0: } max@0: max@0: max@0: max@0: //! @}