OctaveEnvironment Class |
Namespace: Accord.Math.Environments
The OctaveEnvironment type exposes the following members.
Name | Description | |
---|---|---|
OctaveEnvironment |
Initializes a new instance of the OctaveEnvironment class.
|
Name | Description | |
---|---|---|
_ |
Matrix placeholder.
| |
UseOctaveDimensionIndexing |
Whether to use octave indexing or not.
|
Name | Description | |
---|---|---|
abs(Double) | Absolute value. | |
abs(Double) | Absolute value. | |
abs(Double) | Absolute value. | |
ceil(Double) | Ceiling. | |
ceil(Double) | Ceiling. | |
ceil(Double) | Ceiling. | |
chol | Cholesky decomposition. | |
cos(Double) | Cos. | |
cos(Double) | Cos. | |
cos(Double) | Cos. | |
eig(Double, Double) | Eigenvalue decomposition. | |
eig(Double, Double, Double) | Eigenvalue decomposition. | |
eig(Double, Double, Double) | Eigenvalue decomposition. | |
eig(Double, Double, Double, Double) | Eigenvalue decomposition. | |
eig(Double, Double, Double, Double, Double) | Eigenvalue decomposition. | |
eig(Double, Double, Double, Double, Double, Double, Double) | Eigenvalue decomposition. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
exp(Double) | Exponential value. | |
exp(Double) | Exponential value. | |
exp(Double) | Exponential value. | |
eye | Creates an identity matrix. | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
floor(Double) | Flooring. | |
floor(Double) | Flooring. | |
floor(Double) | Flooring. | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
inv | Inverts a matrix. | |
log(Double) | Logarithm. | |
log(Double) | Logarithm. | |
log(Double) | Logarithm. | |
magic | Creates a magic square matrix. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ones(Int32) | Creates a unit matrix. | |
ones(Int32, Int32) | Creates a unit matrix. | |
pinv | Inverts a matrix. | |
prod | Product of vector elements. | |
qr(Double, Double, Double) | QR decomposition. | |
qr(Double, Double, Double, Double) | QR decomposition. | |
rand | Random vector. | |
rank | Rank of a matrix. | |
round(Double) | Rounding. | |
round(Double) | Rounding. | |
round(Double) | Rounding. | |
sin(Double) | Sin. | |
sin(Double) | Sin. | |
sin(Double) | Sin. | |
size | Size of a matrix. | |
sum(Double) | Matrix sum vector. | |
sum(Double) | Sum of vector elements. | |
sum(Double, Int32) | Matrix sum vector. | |
svd | Singular value decomposition. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
zeros(Int32) | Creates a unit matrix. | |
zeros(Int32, Int32) | Creates a unit matrix. |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
This class implements a Domain Specific Language (DSL) for C# which is remarkably similar to Octave. Please take a loook on what is possible to do using this class in the examples section.
To use this class, inherit from OctaveEnvironment. After this step, all code written inside your child class will be able to use the syntax below:
Using the mat and ret keywords, it is possible to replicate most of the Octave environment inside plain C# code. The example below demonstrates how to compute the Singular Value Decomposition of a matrix, which in turn was generated using Magic(Int32).
// Declare local matrices mat u = _, s = _, v = _; // Compute a new mat mat M = magic(3) * 5; // Compute the SVD ret [u, s, v] = svd(M); // Write the matrix string str = u; /* 0.577350269189626 -0.707106781186548 0.408248290463863 u = 0.577350269189626 -1.48007149071427E-16 -0.816496580927726 0.577350269189626 0.707106781186548 0.408248290463863*/
It is also possible to ignore certain parameters by providing a wildcard in the return structure:
// Declare local matrices mat u = _, v = _; // Compute a new mat mat M = magic(3) * 5; // Compute the SVD ret [u, _, v] = svd(M); // the second argument is omitted
Standard matrix operations are also supported:
mat I = eye(3); // 3x3 identity matrix mat A = I * 2; // matrix-scalar multiplication Console.WriteLine(A); // // 2 0 0 // A = 0 2 0 // 0 0 2 mat B = ones(3, 6); // 3x6 unit matrix Console.WriteLine(B); // // 1 1 1 1 1 1 // B = 1 1 1 1 1 1 // 1 1 1 1 1 1 mat C = new double[,] { { 2, 2, 2, 2, 2, 2 }, { 2, 0, 0, 0, 0, 2 }, { 2, 2, 2, 2, 2, 2 }, }; mat D = A * B - C; Console.WriteLine(D); // // 0 0 0 0 0 0 // C = 0 2 2 2 2 0 // 0 0 0 0 0 0