- Accessing elements of an XPE array
- one dimentional
- two dimentional
- multi-dimentional
- Determining the number of dimensions in an XPE array
- Determining the number of elements in XPE array
- one dimensional
- uniform multi-dimensional
- Performing operations on groups of elements of an XPE array
- simple non-optimised access
- optimised access
- creating a new array
- one dimentional
- four dimentional
- named one dimentional XPE array
accessing elements of an XPE array
- simple access to an element of a one dimentional XPE array called 'fred'
XPE::VARIABLE element; element = XPE::get_variable("fred").get_element(n1);the contents of the element can now be accessed in a manor similar to any other XPE variable
- simple access to an element of a two dimentional XPE array called 'fred'
XPE::VARIABLE element; element = XPE::get_variable("fred").get_element(n1, n2);the contents of the element can now be accessed in a manor similar to any other XPE variable
- simple access to an element of a multi-dimentional XPE array called 'fred'
XPE::VARIABLE element; int dim_arr[3]; dim_arr[0] = n1; dim_arr[1] = n2; dim_arr[2] = n3; element = XPE::get_variable("fred").get_array().get_element(3, dim_arr);the contents of the element can now be accessed in a manor similar to any other XPE variable
determining the number of elements in a one dimensional XPE array
int len; len = XPE::get_variable("fred").get_array().get_len();
determining the number of dimensions in an XPE array
int cnt; cnt = XPE::get_variable("fred").get_array().get_dim_cnt();
determining the number of elements in each dimension of a uniform multi-dimensional XPE array
XPE::ARRAY array; int cnt; int size_of_dimension[100]; array = XPE::get_variable("fred").get_array(); cnt = array.get_dim_cnt(); for (int j=0; j<cnt; j++) { size_of_dimension[j] = array.get_dim(j); }
Performing operations on groups of elements of an XPE array
- simple non-optimised access to an XPE array called 'fred'
XPE::VARIABLE element; int len, acc; acc = 0; len = XPE::get_variable("fred").get_array().get_len(); for (int j=0; j<len; j++) { element = XPE::get_variable("fred").get_element(j); acc += element.get_int(); }
- optimised access to an XPE array called 'fred'
XPE::ARRAY array; XPE::VARIABLE element; int len, acc; acc = 0; array = XPE::get_variable("fred").get_array(); len = array.get_len(); for (int j=0; j<len; j++) { element = array.get_element(j); acc += element.get_int(); }
creating a new array
- a one dimentional XPE array
XPE::ARRAY array; int dim_arr[1]; dim_arr[0] = n1; array = XPE::ARRAY(1, dim_arr);
- a four dimentional XPE array
XPE::ARRAY array; int dim_arr[4]; dim_arr[0] = n1; dim_arr[1] = n2; dim_arr[2] = n3; dim_arr[3] = n4; array = XPE::ARRAY(4, dim_arr);
- a one dimentional XPE array called 'fred'
int dim_arr[1]; dim_arr[0] = n1; XPE::get_variable("fred") = XPE::ARRAY(1, dim_arr);