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

Last change on this file since 338 was 338, checked in by smasson, 16 years ago

update documentation

File size: 15.5 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">
179</div>
180
181         
182
183         
184            <h3>Parameters</h3>
185       
186           
187            <h4 id="_cmapply_product_param_x">x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
188             
189             
190             
191             
192             
193             
194             
195             
196            </h4>
197       
198          <div class="comments">
199</div>
200           
201
202         
203
204         
205
206         
207          <h3>Version history</h3>
208         
209          <h4>Version</h4><div class="preformat">
210 $Id: cmapply.pro 325 2007-12-06 10:04:53Z pinsard $
211</div>
212         
213         
214         
215          <h3>Known issues</h3>
216         
217         
218          <h4>Todo items</h4><div class="preformat"> seb</div>
219         
220       
221         
222         
223         
224         
225         
226         
227         
228       
229          <h3>Statistics</h3>
230          <table class="statistics">
231            <tr><td>McCabe cyclic</td><td>           3</td></tr>
232            <tr><td>McCabe essential</td><td>           1</td></tr>
233            <tr><td>McCabe modular design</td><td>           1</td></tr>
234          </table>
235         
236       
237        </div>
238       
239
240        <div class="routine_details" id="_cmapply_redim">
241
242          <h2><a class="top" href="#container">top</a>cmapply_redim </h2>
243       
244          <p class="header">
245            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>
246       
247          <div class="comments">
248</div>
249
250         
251
252         
253            <h3>Parameters</h3>
254       
255           
256            <h4 id="_cmapply_redim_param_newarr">newarr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
257             
258             
259             
260             
261             
262             
263             
264             
265            </h4>
266       
267          <div class="comments">
268</div>
269           
270            <h4 id="_cmapply_redim_param_dimapply">dimapply&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
271             
272             
273             
274             
275             
276             
277             
278             
279            </h4>
280       
281          <div class="comments">
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</div>
297           
298            <h4 id="_cmapply_redim_param_nkeep">nkeep&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
299             
300             
301             
302             
303             
304             
305             
306             
307            </h4>
308       
309          <div class="comments">
310</div>
311           
312            <h4 id="_cmapply_redim_param_totcol">totcol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
313             
314             
315             
316             
317             
318             
319             
320             
321            </h4>
322       
323          <div class="comments">
324</div>
325           
326            <h4 id="_cmapply_redim_param_totkeep">totkeep&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
327             
328             
329             
330             
331             
332             
333             
334             
335            </h4>
336       
337          <div class="comments">
338</div>
339           
340
341         
342
343         
344
345         
346         
347         
348         
349         
350         
351         
352          <h3>Known issues</h3>
353         
354         
355          <h4>Todo items</h4><div class="preformat"> seb
356</div>
357         
358       
359         
360         
361         
362         
363         
364         
365         
366       
367          <h3>Statistics</h3>
368          <table class="statistics">
369            <tr><td>McCabe cyclic</td><td>           4</td></tr>
370            <tr><td>McCabe essential</td><td>           1</td></tr>
371            <tr><td>McCabe modular design</td><td>           1</td></tr>
372          </table>
373         
374       
375        </div>
376       
377
378        <div class="routine_details" id="_cmapply">
379
380          <h2><a class="top" href="#container">top</a>cmapply <span class="categories">
381 Array
382</span></h2>
383       
384          <p class="header">
385            <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>
386       
387          <div class="comments">
388</div>
389
390          <h3>Return value</h3><div class="preformat">
391 An array of the required TYPE, whose elements are the result of
392 the requested operation.  Depending on the operation and number of
393 elements in the input array, the result may be vulnerable to
394 overflow or underflow.
395</div>
396
397         
398            <h3>Parameters</h3>
399       
400           
401            <h4 id="_cmapply_param_op">op&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
402              <span class="attr">in</span>
403             
404             
405              <span class="attr">required</span>
406             
407              <span class="attr">type:</span> <span class="value">string</span>
408             
409             
410            </h4>
411       
412          <div class="comments">
413 The operation to perform, as a string.  May be upper or lower case.
414
415 If a user-defined operation is to be passed, then OP is of
416 the form, 'USER:FUNCTNAME', where FUNCTNAME is the name of
417 the user-defined function.
418</div>
419           
420            <h4 id="_cmapply_param_array">array&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
421              <span class="attr">in</span>
422             
423             
424              <span class="attr">required</span>
425             
426              <span class="attr">type:</span> <span class="value">array</span>
427             
428             
429            </h4>
430       
431          <div class="comments">
432 An array of values to be operated on.
433 Must not be of type STRING (7) or STRUCTURE (8).
434</div>
435           
436            <h4 id="_cmapply_param_dimapply">dimapply&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
437              <span class="attr">in</span>
438             
439              <span class="attr">optional</span>
440             
441             
442              <span class="attr">type:</span> <span class="value">array</span>
443              <span class="attr">default:</span> <span class="value">1 (ie, first dimension)</span>
444             
445            </h4>
446       
447          <div class="comments">
448 An array of dimensions that are to be "collapsed", where
449 the first dimension starts with 1 (ie, same convention
450 as IDL function TOTAL).  Whereas TOTAL only allows one
451 dimension to be added, you can specify multiple dimensions
452 to CMAPPLY.  Order does not matter, since all operations
453 are associative and transitive.  NOTE: the dimensions refer
454 to the *input* array, not the output array.  IDL allows a
455 maximum of 8 dimensions.
456</div>
457           
458
459         
460
461         
462
463            <h3>Keywords</h3>
464           
465            <h4 id="_cmapply_keyword_DOUBLE">DOUBLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
466             
467             
468             
469             
470             
471             
472              <span class="attr">default:</span> <span class="value">not set</span>
473             
474            </h4>
475       
476            <div class="comments">
477 Set this if you wish the internal computations to be done
478 in double precision if necessary.  If ARRAY is double
479 precision (real or complex) then DOUBLE=1 is implied.
480</div>
481           
482            <h4 id="_cmapply_keyword_TYPE">TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
483             
484             
485             
486             
487             
488             
489              <span class="attr">default:</span> <span class="value">same as input type</span>
490             
491            </h4>
492       
493            <div class="comments">
494 Set this to the IDL code of the desired output type (refer
495 to documentation of <a href="/Applications/itt/idl64/help/online_help/SIZE.html">SIZE</a>). Internal results will be
496 rounded to the nearest integer if the output type is an
497 integer type.
498</div>
499           
500            <h4 id="_cmapply_keyword_FUNCTARGS">FUNCTARGS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
501             
502             
503             
504             
505             
506             
507             
508             
509            </h4>
510       
511            <div class="comments">
512 If OP is 'USER:...', then the contents of this keyword
513 are passed to the user function using the _EXTRA
514 mechanism.  This way you can pass additional data to
515 your user-supplied function, via keywords, without
516 using common blocks.
517 DEFAULT: undefined (i.e., no keywords passed by _EXTRA)
518</div>
519           
520            <h4 id="_cmapply_keyword_NOCATCH">NOCATCH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
521             
522             
523             
524             
525             
526             
527             
528             
529            </h4>
530       
531            <div class="comments"></div>
532           
533         
534
535          <h3>Examples</h3><div class="preformat">
536
537   First example: 
538   Shows how <a href="..//Matrix/cmapply.html">cmapply</a> can be used to total the second dimension of
539   the array called IN. This is equivalent to OUT = TOTAL(IN, 2)
540
541   IDL> IN  = INDGEN(5,5)
542   IDL> OUT = CMAPPLY('+', IN, [2])
543   IDL> HELP, OUT
544   OUT             INT       = Array[5]
545
546   Second example:  Input is assumed to be an 5x100 array of 1's and
547   0's indicating the status of 5 detectors at 100 points in time.
548   The desired output is an array of 100 values, indicating whether
549   all 5 detectors are on (=1) at one time.  Use the logical AND
550   operation.
551
552   IDL> IN = detector_status             ; 5x100 array
553   IDL> OUT = CMAPPLY('AND', IN, [1])    ; collapses 1st dimension
554   IDL> HELP, OUT
555   OUT             BYTE      = Array[100]
556
557   (note that MIN could also have been used in this particular case,
558   although there would have been more loop iterations).
559
560   Third example:  Shows sum over first and third dimensions in an
561   array with dimensions 4x4x4:
562
563   IDL> IN = INDGEN(4,4,4)
564   IDL> OUT = CMAPPLY('+', IN, [1,3])
565   IDL> PRINT, OUT
566        408     472     536     600
567
568   Fourth example:  A user-function (MEDIAN) is used:
569
570   IDL> IN = RANDOMN(SEED,10,10,5)
571   IDL> OUT = CMAPPLY('USER:MEDIAN', IN, 3)
572   IDL> HELP, OUT
573   OUT             FLOAT     = Array[10, 10]
574
575   (OUT[i,j] is the median value of IN[i,j,*])
576</div>
577          <h3>Version history</h3>
578         
579          <h4>Version</h4><div class="preformat">
580 $Id: cmapply.pro 325 2007-12-06 10:04:53Z pinsard $
581</div>
582          <h4>History</h4><div class="preformat">
583 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.