source: trunk/SRC/Documentation/idldoc_html_output/Matrix/cmapply.html @ 191

Last change on this file since 191 was 191, checked in by pinsard, 18 years ago

remove format=raw in all html files 2+ : correction for all_plots; suppression of css and correction of Source links in idldoc html output

File size: 15.4 KB
Line 
1
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<!-- Generated by IDLdoc 2.0 -->
6
7<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8  <head>
9    <title>cmapply.pro (SAXO Documentation)</title>
10
11   
12    <link rel="stylesheet" type="text/css" media="all" href="./../main_files.css" />
13    <link rel="stylesheet" type="text/css" media="print" href="./../main_files_print.css" />
14   
15
16    <script type="text/javascript">
17      function setTitle() {
18        parent.document.title="cmapply.pro (SAXO Documentation)";
19      }
20    </script>
21  </head>
22
23  <body onload="setTitle();">
24
25    <div id="navbar_title">
26  <h1>SAXO Documentation</h1>
27</div>
28
29
30<div id="main_navbar">
31
32  <table cellspacing="0">
33    <tr>
34     
35      <td><a href="./../overview.html" title="Overview of library">Overview</a></td>
36     
37
38     
39      <td >Directory</td>
40     
41
42     
43      <td><a href="./../idldoc-categories.html" title="Browse library by category">Categories</a></td>
44     
45
46     
47      <td><a href="./../idldoc-index.html" title="Index of files, routines, and parameters">Index</a></td>
48     
49
50     
51      <td><a href="./../search-page.html" title="Search library">Search</a></td>
52     
53
54      <td id="selected">File</td>
55
56     
57      <td><a href="../../../Matrix//cmapply.pro" title="Source code of a file">Source</a></td>
58     
59
60     
61      <td><a href="./../idldoc-help.html" title="Help on IDLdoc">Help</a></td>
62     
63
64      <td >Etc</td>
65
66      <td id="flexible">Developer&nbsp;documentation</td>
67    </tr>
68  </table>
69
70</div>
71
72<div id="secondary_navbar">
73
74&lt;&lt; prev file | <a href="cmset_op.html">next file &gt;&gt;</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="cmapply.html" target="_TOP">view single page</a> | <a href="./../index.html" target="_TOP">view frames</a>&nbsp;&nbsp;&nbsp;&nbsp;summary: fields | <a href="#routine_summary">routine</a>&nbsp;&nbsp;&nbsp;&nbsp;details: <a href="#routine_details">routine</a>
75
76</div>
77
78
79    <div id="container">
80
81      <h1 class="directory"><a href="directory-overview.html">Matrix/</a></h1>
82      <h2 class="pro_file">cmapply.pro</h2>
83
84      <div id="file_attr">
85        <dl>
86        </dl>
87      </div>
88
89      <div id="file_comments">
90 Utility function, adapted from CMPRODUCT
91
92
93 cmapply_redim : Utility function, used to collect collaped dimensions
94
95
96 Applies a function to specified dimensions of an array
97
98 Description:
99
100 CMAPPLY will apply one of a few select functions to specified
101 dimensions of an array.  Unlike some IDL functions, you *do* have
102 a choice of which dimensions that are to be "collapsed" by this
103 function.  Iterative loops are avoided where possible, for
104 performance reasons.
105
106   The possible functions are:             (and number of loop iterations:)
107     +     - Performs a sum (as in TOTAL)       number of collapsed dimensions
108     AND   - Finds LOGICAL "AND" (not bitwise)  same
109     OR    - Finds LOGICAL "OR"  (not bitwise)  same
110     *     - Performs a product                 LOG_2[no. of collapsed elts.]
111
112     MIN   - Finds the minimum value            smaller of no. of collapsed
113     MAX   - Finds the maximum value            or output elements
114
115     USER  - Applies user-defined function      no. of output elements
116
117
118   It is possible to perform user-defined operations arrays using
119   CMAPPLY.  The OP parameter is set to 'USER:FUNCTNAME', where
120   FUNCTNAME is the name of a user-defined function.  The user
121   defined function should be defined such that it accepts a single
122   parameter, a vector, and returns a single scalar value.  Here is a
123   prototype for the function definition:
124
125      FUNCTION FUNCTNAME, x, KEYWORD1=key1, ...
126         scalar = ... function of x or keywords ...
127         RETURN, scalar
128      END
129
130   The function may accept keywords.  Keyword values are passed in to
131   CMAPPLY through the FUNCTARGS keywords parameter, and passed to
132   the user function via the _EXTRA mechanism.  Thus, while the
133   definition of the user function is highly constrained in the
134   number of positional parameters, there is absolute freedom in
135   passing keyword parameters.
136
137   It's worth noting however, that the implementation of user-defined
138   functions is not particularly optimized for speed.  Users are
139   encouraged to implement their own array if the number of output
140   elements is large.
141</div>
142
143     
144
145     
146
147     
148
149     
150      <div id="routine_summary">               
151        <h2>Routine summary</h2>
152       
153        <dl>
154         
155          <dt><p><a href="#_cmapply_product"><span class="result">result = </span>cmapply_product(<span class="result">x</span>)</a></p><dt>
156          <dd></dd>     
157         
158          <dt><p><a href="#_cmapply_redim">cmapply_redim<span class="result">, newarr, dimapply, dimkeep, nkeep, totcol, totkeep</span></a></p><dt>
159          <dd></dd>     
160         
161          <dt><p><a href="#_cmapply"><span class="result">result = </span>cmapply(<span class="result">op, array[, dimapply]</span>, double=<span class="result">double</span>, type=<span class="result">type</span>, functargs=<span class="result">functargs</span>, nocatch=<span class="result">nocatch</span>)</a></p><dt>
162          <dd> </dd>   
163               
164        </dl>
165      </div>
166     
167
168      <div id="routine_details">
169       
170
171        <div class="routine_details" id="_cmapply_product">
172
173          <h2><a class="top" href="#container">top</a>cmapply_product </h2>
174       
175          <p class="header">
176            <span class="result">result = </span>cmapply_product(<span class="result"><a href="#_cmapply_product_param_x">x</a></span>)</p>
177       
178          <div class="comments"></div>
179
180         
181
182         
183            <h3>Parameters</h3>
184       
185           
186            <h4 id="_cmapply_product_param_x">x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
187             
188             
189             
190             
191             
192             
193             
194             
195            </h4>
196       
197          <div class="comments">
198
199</div>
200           
201
202         
203
204         
205
206         
207          <h3>Version history</h3>
208         
209          <h4>Version</h4><div class="preformat"> $Id: cmapply.pro 163 2006-08-29 12:59:46Z navarro $
210</div>
211         
212         
213         
214          <h3>Known issues</h3>
215         
216         
217          <h4>Todo items</h4><div class="preformat"> seb</div>
218         
219       
220         
221         
222         
223         
224         
225         
226         
227       
228          <h3>Statistics</h3>
229          <table class="statistics">
230            <tr><td>McCabe cyclic</td><td>           3</td></tr>
231            <tr><td>McCabe essential</td><td>           1</td></tr>
232            <tr><td>McCabe modular design</td><td>           1</td></tr>
233          </table>
234         
235       
236        </div>
237       
238
239        <div class="routine_details" id="_cmapply_redim">
240
241          <h2><a class="top" href="#container">top</a>cmapply_redim </h2>
242       
243          <p class="header">
244            cmapply_redim<span class="result">, <a href="#_cmapply_redim_param_newarr">newarr</a>, <a href="#_cmapply_redim_param_dimapply">dimapply</a>, <a href="#_cmapply_redim_param_dimkeep">dimkeep</a>, <a href="#_cmapply_redim_param_nkeep">nkeep</a>, <a href="#_cmapply_redim_param_totcol">totcol</a>, <a href="#_cmapply_redim_param_totkeep">totkeep</a></span></p>
245       
246          <div class="comments"></div>
247
248         
249
250         
251            <h3>Parameters</h3>
252       
253           
254            <h4 id="_cmapply_redim_param_newarr">newarr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
255             
256             
257             
258             
259             
260             
261             
262             
263            </h4>
264       
265          <div class="comments">
266
267</div>
268           
269            <h4 id="_cmapply_redim_param_dimapply">dimapply&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
270             
271             
272             
273             
274             
275             
276             
277             
278            </h4>
279       
280          <div class="comments">
281
282</div>
283           
284            <h4 id="_cmapply_redim_param_dimkeep">dimkeep&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
285             
286             
287             
288             
289             
290             
291             
292             
293            </h4>
294       
295          <div class="comments">
296
297</div>
298           
299            <h4 id="_cmapply_redim_param_nkeep">nkeep&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
300             
301             
302             
303             
304             
305             
306             
307             
308            </h4>
309       
310          <div class="comments">
311
312</div>
313           
314            <h4 id="_cmapply_redim_param_totcol">totcol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
315             
316             
317             
318             
319             
320             
321             
322             
323            </h4>
324       
325          <div class="comments">
326
327</div>
328           
329            <h4 id="_cmapply_redim_param_totkeep">totkeep&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
330             
331             
332             
333             
334             
335             
336             
337             
338            </h4>
339       
340          <div class="comments">
341
342</div>
343           
344
345         
346
347         
348
349         
350         
351         
352         
353         
354         
355         
356          <h3>Known issues</h3>
357         
358         
359          <h4>Todo items</h4><div class="preformat"> seb</div>
360         
361       
362         
363         
364         
365         
366         
367         
368         
369       
370          <h3>Statistics</h3>
371          <table class="statistics">
372            <tr><td>McCabe cyclic</td><td>           4</td></tr>
373            <tr><td>McCabe essential</td><td>           1</td></tr>
374            <tr><td>McCabe modular design</td><td>           1</td></tr>
375          </table>
376         
377       
378        </div>
379       
380
381        <div class="routine_details" id="_cmapply">
382
383          <h2><a class="top" href="#container">top</a>cmapply <span class="categories"> 
384 Array
385</span></h2>
386       
387          <p class="header">
388            <span class="result">result = </span>cmapply(<span class="result"><a href="#_cmapply_param_op">op</a>, <a href="#_cmapply_param_array">array</a>[, <a href="#_cmapply_param_dimapply">dimapply</a>]</span>, <a href="#_cmapply_keyword_double">double</a>=<span class="result">double</span>, <a href="#_cmapply_keyword_type">type</a>=<span class="result">type</span>, <a href="#_cmapply_keyword_functargs">functargs</a>=<span class="result">functargs</span>, <a href="#_cmapply_keyword_nocatch">nocatch</a>=<span class="result">nocatch</span>)</p>
389       
390          <div class="comments">
391</div>
392
393          <h3>Return value</h3><div class="preformat">
394 An array of the required TYPE, whose elements are the result of
395 the requested operation.  Depending on the operation and number of
396 elements in the input array, the result may be vulnerable to
397 overflow or underflow.
398</div>
399
400         
401            <h3>Parameters</h3>
402       
403           
404            <h4 id="_cmapply_param_op">op&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
405              <span class="attr">in</span>
406             
407             
408              <span class="attr">required</span>
409             
410              <span class="attr">type:</span> <span class="value">string</span>
411             
412             
413            </h4>
414       
415          <div class="comments">
416 The operation to perform, as a string.  May be upper or lower case.
417
418 If a user-defined operation is to be passed, then OP is of
419 the form, 'USER:FUNCTNAME', where FUNCTNAME is the name of
420 the user-defined function.
421</div>
422           
423            <h4 id="_cmapply_param_array">array&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
424              <span class="attr">in</span>
425             
426             
427              <span class="attr">required</span>
428             
429              <span class="attr">type:</span> <span class="value">array</span>
430             
431             
432            </h4>
433       
434          <div class="comments"> 
435 An array of values to be operated on.
436 Must not be of type STRING (7) or STRUCTURE (8).
437</div>
438           
439            <h4 id="_cmapply_param_dimapply">dimapply&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
440              <span class="attr">in</span>
441             
442              <span class="attr">optional</span>
443             
444             
445              <span class="attr">type:</span> <span class="value">array</span>
446              <span class="attr">default:</span> <span class="value">1 (ie, first dimension)</span>
447             
448            </h4>
449       
450          <div class="comments">
451 An array of dimensions that are to be "collapsed", where
452 the the first dimension starts with 1 (ie, same convention
453 as IDL function TOTAL).  Whereas TOTAL only allows one
454 dimension to be added, you can specify multiple dimensions
455 to CMAPPLY.  Order does not matter, since all operations
456 are associative and transitive.  NOTE: the dimensions refer
457 to the *input* array, not the output array.  IDL allows a
458 maximum of 8 dimensions.
459</div>
460           
461
462         
463
464         
465
466            <h3>Keywords</h3>
467           
468            <h4 id="_cmapply_keyword_double">double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
469             
470             
471             
472             
473             
474             
475              <span class="attr">default:</span> <span class="value">not set</span>
476             
477            </h4>
478       
479            <div class="comments">
480 Set this if you wish the internal computations to be done
481 in double precision if necessary.  If ARRAY is double
482 precision (real or complex) then DOUBLE=1 is implied.
483</div>
484           
485            <h4 id="_cmapply_keyword_type">type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
486             
487             
488             
489             
490             
491             
492              <span class="attr">default:</span> <span class="value">same as input type</span>
493             
494            </h4>
495       
496            <div class="comments">
497 Set this to the IDL code of the desired output type (refer
498 to documentation of SIZE()).  Internal results will be
499 rounded to the nearest integer if the output type is an
500 integer type.
501</div>
502           
503            <h4 id="_cmapply_keyword_functargs">functargs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
504             
505             
506             
507             
508             
509             
510             
511             
512            </h4>
513       
514            <div class="comments">
515 If OP is 'USER:...', then the contents of this keyword
516 are passed to the user function using the _EXTRA
517 mechanism.  This way you can pass additional data to
518 your user-supplied function, via keywords, without
519 using common blocks.
520 DEFAULT: undefined (i.e., no keywords passed by _EXTRA)
521</div>
522           
523            <h4 id="_cmapply_keyword_nocatch">nocatch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
524             
525             
526             
527             
528             
529             
530             
531             
532            </h4>
533       
534            <div class="comments"></div>
535           
536         
537
538          <h3>Examples</h3><div class="preformat">
539
540   First example:  Shows how CMAPPLY can be used to total the second dimension of the
541   array called IN.  This is equivalent to OUT = TOTAL(IN, 2)
542
543   IDL> IN  = INDGEN(5,5)
544   IDL> OUT = CMAPPLY('+', IN, [2])
545   IDL> HELP, OUT
546   OUT             INT       = Array[5]
547
548   Second example:  Input is assumed to be an 5x100 array of 1's and
549   0's indicating the status of 5 detectors at 100 points in time.
550   The desired output is an array of 100 values, indicating whether
551   all 5 detectors are on (=1) at one time.  Use the logical AND
552   operation.
553
554   IDL> IN = detector_status             ; 5x100 array
555   IDL> OUT = CMAPPLY('AND', IN, [1])    ; collapses 1st dimension
556   IDL> HELP, OUT
557   OUT             BYTE      = Array[100]
558
559   (note that MIN could also have been used in this particular case,
560   although there would have been more loop iterations).
561
562   Third example:  Shows sum over first and third dimensions in an
563   array with dimensions 4x4x4:
564
565   IDL> IN = INDGEN(4,4,4)
566   IDL> OUT = CMAPPLY('+', IN, [1,3])
567   IDL> PRINT, OUT
568        408     472     536     600
569
570   Fourth example:  A user-function (MEDIAN) is used:
571
572   IDL> IN = RANDOMN(SEED,10,10,5)
573   IDL> OUT = CMAPPLY('USER:MEDIAN', IN, 3)
574   IDL> HELP, OUT
575   OUT             FLOAT     = Array[10, 10]
576
577   (OUT[i,j] is the median value of IN[i,j,*])
578</div>
579          <h3>Version history</h3>
580         
581          <h4>Version</h4><div class="preformat"> $Id: cmapply.pro 163 2006-08-29 12:59:46Z navarro $
582</div>
583          <h4>History</h4><div class="preformat"> Mar 1998, Written, CM
584   Changed usage message to not bomb, 24 Mar 2000, CM
585   Significant rewrite for *, MIN and MAX (inspired by Todd Clements
586     <Todd_Clements@alumni.hmc.edu>); FOR loop indices are now type
587     LONG; copying terms are liberalized, CM, 22, Aug 2000
588   More efficient MAX/MIN (inspired by Alex Schuster), CM, 25 Jan
589     2002
590   Make new MAX/MIN actually work with 3d arrays, CM, 08 Feb 2002
591   Add user-defined functions, ON_ERROR, CM, 09 Feb 2002
592   Correct bug in MAX/MIN initialization of RESULT, CM, 05 Dec 2002
593
594  Author: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
595  craigm@lheamail.gsfc.nasa.gov
596</div>
597         
598         
599         
600         
601         
602         
603         
604       
605         
606         
607         
608         
609         
610         
611         
612       
613          <h3>Statistics</h3>
614          <table class="statistics">
615            <tr><td>McCabe cyclic</td><td>          36</td></tr>
616            <tr><td>McCabe essential</td><td>           1</td></tr>
617            <tr><td>McCabe modular design</td><td>           1</td></tr>
618          </table>
619         
620       
621        </div>
622       
623      </div>
624
625     
626
627      <div id="tagline">Produced by IDLdoc 2.0.</div>
628
629    </div>
630
631  </body>
632</html>
Note: See TracBrowser for help on using the repository browser.