~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/statistics/nanmax.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [s,index] = nanmax(x,orient)
 
2
//
 
3
//This function gives for a  real or a  numerical matrix x a his largest
 
4
//element m (but ignoring the NANs).
 
5
//
 
6
//For x,  a numerical vector or matrix,  m=nanmax(x) returns in scalar m
 
7
//the largest  element of x (ignoring the  NANs).  The form  [m,index] =
 
8
//nanmax(x,orient) gives in addition of the value of the largest element
 
9
//of x (ignoring the NANs) in scalar m, and    the index of this element
 
10
//in x, as a  2-vector.
 
11
//
 
12
//m=nanmax(x,'r') gives in the 1xsize(x,2) matrix m the largest elements
 
13
//(ignoring the    NANs)   of each   column    of  x.   If   the    form
 
14
//[m,index]=nanmax(x,'r')  is used,    the elements of  the  1xsize(x,2)
 
15
//matrix index are the indexes  of the  largest  elements  (ignoring the
 
16
//NANs) of each column of x in the corresponding column.
 
17
//
 
18
//m=nanmax(x,'c') gives in the size(x,2)x1 matrix m the largest elements
 
19
//(ignoring    the    NANs) of    each   row   of   x.    If  the   form
 
20
//[m,index]=nanmax(x,'c') is  used,   the  elements of   the size(x,2)x1
 
21
//matrix index are  the  indexes of the  largest  elements (ignoring the
 
22
//NANs) of each row of x in the corresponding row.
 
23
//
 
24
//author: carlos klimann
 
25
//
 
26
//date: 2000-01-14
 
27
//
 
28
    
 
29
  if argn(2)==1 then  orient='*',end
 
30
  if orient==1 then orient='r',end
 
31
  if orient==2 then orient='c',end
 
32
  if x==[]|(size(x,'*')==1&isnan(x)) then s=[],index=[],return,end
 
33
  isn=isnan(x)
 
34
  x(isn)=%inf
 
35
  [s,index]=max(x,orient)
 
36
  s(find(and(isn,orient)))=%nan
 
37
 
 
38
endfunction