Vectors have two dimensions, but one of those dimensions must be unitary. Vector instances can be constructed in a more straightforward manner by leaving the dimensions array out. The default is to create a row vector:
Dim elements As Double() = New Double(9) {}
Dim x As New Vector(elements)
double[] elements = new double[10];
Vector x = new Vector(elements);
If one desires an equivalent column vector, this can be done in two ways. The following snippet demonstrates the two approaches:
'This approach creates a row Vector and then transposes it to a column vector.
Dim elements As Double() = New Double(9) {}
Dim x As New Vector(elements)
x.Transpose()
'Similar to the above approach, but
'with the Compute.Transpose method.
Dim elements As Double() = New Double(9) {}
Dim x As New Vector(elements)
x = Compute.Transpose(x)
//This approach creates a row Vector and then transposes it to a column vector.
double[] elements = new double[10];
Vector x = new Vector(elements);
x.Transpose();
//Similar to the above approach, but
//with the Compute.Transpose method.
double[] elements = new double[10];
Vector x = new Vector(elements);
x = Compute.Transpose(x);
These are not two different ways of specifying the same operation. In the instance method, the dimensions integer array is changed on the instance itself. In the second case, the data is copied into a new vector and then the data is transposed. It is worth noting that the instance methods will still return the modified vector. This allows mathematical operations to be chained. For this reason, instance method calls can be assigned to new variables.
In the following code snippet, the variables will point to the same memory locations:
Dim elements As Double() = New Double(9) {}
Dim x1 As New Vector(elements)
Dim x2 As Vector = x1.Transpose()
double[] elements = new double[10];
Vector x1 = new Vector(elements);
Vector x2 = x1.Transpose();
In the above snippet, both x1 and x2 will be column Vectors. In fact, they will be the same vector.