Difference between revisions of "Size"

m (adding doc status category)
Line 2: Line 2:
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
  
Size(A) returns the total number of elements in an array.
+
= Size(A) =
  
When used on an index, Size(I) returns the length of the index.
+
[[Size]](A) returns the total number of elements in an array.
 +
 
 +
When applied to a scalar (a zero-dimensional array), it returns 1.
 +
 
 +
[[Size]] does not count elements that are contained within a [[Using References|reference]].  So if a [[Using References|reference]] occurs in a cell of an array, it will be counted as one, even if it points to an array that contains many cells.
 +
 
 +
= Library =
 +
 
 +
Array library
 +
 
 +
= Length of an index =
 +
 
 +
When used on an index, [[Size]](I) returns the length of the index. However, be careful -- if used with a self-indexed array, it is the size of the array, not the size of the index, that is returned.  When an array is one-dimensional, these are the same, but a self-indexed array could be multi-dimensional.  Two safer ways to obtain the length of an index are:
 +
[[Size]]([[IndexValue]](I))
 +
or
 +
[[Sum]](1,I)
 +
 
 +
= Length of the [[Implicit Dimensions|implicit dimension]] =
 +
 
 +
All dimensions of an Analytica array correspond to an explicit index object, except for one -- the [[Implicit Dimensions|implicit dimension]].  See the article [[Implicit Dimensions]] for more details. 
 +
 
 +
(''new to 4.2'') When ''A'' has an implicit dimension, its length can be obtained using:
 +
[[Size]](A,listLen:true)
 +
 
 +
You can also use this to determine the number of [[Function Parameter Qualifiers#Ellipsis|repeated parameters]] supplied to a [[User-Defined Function]].  For example:
 +
Function GeoAve(x : ... Number )
 +
Definition: [[Exp]]([[Sum]]([[Ln]](x))/[[Size]](x,ListLen:true))
 +
 
 +
= Array Abstraction Considerations =
 +
 
 +
Although [[Size]] does return a result when the number of dimensions of an array changes, this function does not strictly obey the ''law of array abstraction''.  This is because it operations over all indexes that are present, rather than only over a set of explicit specified indexes.  Because of this, if used inappropriately within a model, incorrect results from [[Parametric Analyses]] could result.
 +
 
 +
= See Also =
 +
 
 +
* [[Sum]]
 +
* [[Implicit Dimensions]]

Revision as of 23:12, 5 November 2008


Size(A)

Size(A) returns the total number of elements in an array.

When applied to a scalar (a zero-dimensional array), it returns 1.

Size does not count elements that are contained within a reference. So if a reference occurs in a cell of an array, it will be counted as one, even if it points to an array that contains many cells.

Library

Array library

Length of an index

When used on an index, Size(I) returns the length of the index. However, be careful -- if used with a self-indexed array, it is the size of the array, not the size of the index, that is returned. When an array is one-dimensional, these are the same, but a self-indexed array could be multi-dimensional. Two safer ways to obtain the length of an index are:

Size(IndexValue(I))

or

Sum(1,I)

Length of the implicit dimension

All dimensions of an Analytica array correspond to an explicit index object, except for one -- the implicit dimension. See the article Implicit Dimensions for more details.

(new to 4.2) When A has an implicit dimension, its length can be obtained using:

Size(A,listLen:true)

You can also use this to determine the number of repeated parameters supplied to a User-Defined Function. For example:

Function GeoAve(x : ... Number )
Definition: Exp(Sum(Ln(x))/Size(x,ListLen:true))

Array Abstraction Considerations

Although Size does return a result when the number of dimensions of an array changes, this function does not strictly obey the law of array abstraction. This is because it operations over all indexes that are present, rather than only over a set of explicit specified indexes. Because of this, if used inappropriately within a model, incorrect results from Parametric Analyses could result.

See Also

Comments


You are not allowed to post comments.