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_min max@0: //! @{ max@0: max@0: //! \brief max@0: //! Delayed 'minimum values' operation. max@0: //! The dimension, along which the minima are found, is set via 'dim'. max@0: //! For dim = 0, the minimum value of each column is found (i.e. searches by traversing across rows). max@0: //! For dim = 1, the minimum 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: min(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 minimum value in a row vector' operation max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: min(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), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(A.mem, A_n_elem); max@0: } max@0: max@0: max@0: max@0: //! Immediate 'find the minimum value in a column vector' max@0: template max@0: inline max@0: arma_warn_unused max@0: eT max@0: min(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), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(A.mem, A_n_elem); max@0: } max@0: max@0: max@0: max@0: //! \brief max@0: //! Immediate 'find minimum value' operation, max@0: //! invoked, for example, by: min(min(A)) max@0: template max@0: inline max@0: arma_warn_unused max@0: typename T1::elem_type max@0: min(const Op& in) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_extra_debug_print("min(): two consecutive min() 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), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(X.mem, X_n_elem); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: const Op< Op, op_min> max@0: min(const Op& in, const uword dim) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return Op< Op, op_min>(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: min(const subview_row& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(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: min(const subview_col& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(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: min(const diagview& A) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(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: min(const Op, op_min>& in) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_extra_debug_print("min(): two consecutive min() calls detected"); max@0: max@0: const subview& X = in.m; max@0: max@0: arma_debug_check( (X.n_elem == 0), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(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: min(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), "min(): given object has no elements" ); max@0: max@0: return op_min::direct_min(X.mem, X_n_elem); max@0: } max@0: max@0: max@0: max@0: //! @}