October 13, 2003

TransposeMatrix – Evaluate the transposed matrix

‘ Evaluate the transposed matrix’ A transposed matrix is the array you get when you “rotate” a bi-dimensional ‘ array” Example’ Dim arr(,) As Double = {{0.0, 0.1, 0.2}, {1.0, 1.1, 1.2}}’ Dim i, j As Integer’ ‘ print the original matrix’ Debug.WriteLine(“Original matrix”)’ For i = 0 To arr.GetUpperBound(0)’

SwapArrayItems – Swap two elements in the input array

‘ Swap two elements in the input array” Example:’ Dim arr As Integer() = {3, 7, 8, 2, 0, 9}’ SwapArrayItems(arr, 1, 4)’ Dim o As Object’ For Each o In arr’ Debug.Write(o & ” “)’ Next’ Debug.WriteLine(“”)Sub SwapArrayItems(ByVal arr As Array, ByVal index1 As Integer, _ ByVal index2 As

ArrayAvg – The average of an array of any numeric type

‘ The average of an array of any numeric type” Example:’ Dim arr As Integer() = {3, 7, 8, 2, 0, 9}’ MessageBox.Show(ArrayAvg(arr))Function ArrayAvg(ByVal arr As Array) As Double Return ArrayAvg(arr, arr.GetLowerBound(0), arr.GetUpperBound(0))End Function’ This overloaded version allows you to specify which portion of the array ‘ should be consideredFunction

ArrayFilter – Filtering arrays of any type, with many options

‘ Filter the input array. It can work with string arrays or arrays of other ‘ type!’ The input array is modified by removing the elements that do not match the ‘ filter options, but the array is not actually re-sized. The filter results ‘ will be moved at the

FillRandomArray – Fill the input array with random values

‘ Fill the input array with random values” Example:’ Dim arr(9) As Integer’ FillRandomArray(arr, 1, 11)’ Dim i As Integer’ For i = 0 To 9′ Debug.Write(arr(i) & ” “)’ Next’ Debug.WriteLine(“”)Sub FillRandomArray(ByVal arr As Array) FillRandomArray(arr, Integer.MinValue, Integer.MaxValue)End Sub’ This overloaded version allows you to specify the min-max range

ArraySum – The sum of an array of any numeric type

‘ The sum of an array of any numeric type” Example:’ Dim arr As Integer() = {3, 7, 8, 2, 0, 9}’ MessageBox.Show(ArraySum(arr))Function ArraySum(ByVal arr As Array) As Double Return ArraySum(arr, arr.GetLowerBound(0), arr.GetUpperBound(0))End Function’ This overloaded version allows you to specify which portion of the array ‘ should be consideredFunction