Array Functions |
|
Array Functions SupportThe Fractal Science Kit fractal generator Array functions are useful when working with arrays. Array.Dim1(<Array>) Array.Dim1 returns the size of an array's 1st dimension. Array.Dim2 returns the size of an array's 2nd dimension. Example: n = Array.Dim1(vector[]) This example sets n equal to the size of the array vector[]; i.e., n is set to the number of items in the 1-dimensional array vector[]. Example: rows = Array.Dim1(table[,]) This example sets rows equal to the size of the 1st dimension of the array table[,] and cols equal to the size of the 2nd dimension. void Array.ReDim(a[], count) Array.ReDim resets the dimensions of the 1-dimensional array a[] to count. void Array.Copy(src[], srcIndex, dst[], dstIndex, count) Array.Copy copies items from one array to another. Specifically, it copies the count items in the array src[], starting at srcIndex, into the array dst[], starting at dstIndex. In most cases the source and destination array will have the same type and rank but this is not required. If the source or destination arrays are 2-dimensional arrays, the index is a relative offset into the array. Example: Complex data1[6,4] This example fills m[] with 12 Mobius objects using the data given in the 2 arrays data1[,] and data2[,]. Since the source arrays are of type Complex, the count argument is the number of Complex elements to copy (24), and these are mapped onto 6 Mobius objects, each with 4 fields. While this type of usage should be avoided for the sake of code clarity, it can be useful in selected circumstances. void Array.Append(a[], item1, item2, ...) Array.Append adds the given items to the end of the array. Array.AppendArray adds the items found in the array items[] to the end of the array. In both cases, the size of the array a[] is increased by the number of items. The type of the array a[] must must match the items you are adding. Array.AppendValue adds count copies of value to the end of the array. The type of the array a[] must must match the type of value. Complex Array.Offset(array[,], row, col) = row*Array.Dim2(array[,])+col Array.Offset returns the offset into the 2-dimensional array[,] of the item at the given row and col. void Array.Clear(a[]) Array.Clear sets all the elements of array a[] to 0. If a[] is an array of objects, it sets all fields in all objects to 0. void Array.Fill(a[], v) Array.Fill sets all the elements of array a[] (or a[,]) to v. The array a[] must be an array of complex values (i.e., not objects). void Array.Reverse(a[]) Array.Reverse reverses the elements of the 1-dimensional array a[]. a[] is an array complex values or objects. Complex Array.ProductSum(z0[], z1[]) Array.ProductSum returns the sum of the products of the corresponding elements of the 1-dimensional arrays z0[] and z1[]. Both arrays must have the same dimension and contain complex values (i.e., not objects). Complex Array.Min(a[]) Array.Min returns the minimum value found in the array a[]. The array a[] must be an array of real values (i.e., not Complex values or objects). Array.Max returns the maximum value found in the array a[]. |
Copyright © 2004-2019 Ross Hilbert |