Click or drag to resize
Accord.NET (logo)

OctaveEnvironment Class

Programming environment for Octave.
Inheritance Hierarchy
SystemObject
  Accord.Math.EnvironmentsOctaveEnvironment

Namespace:  Accord.Math.Environments
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public abstract class OctaveEnvironment
Request Example View Source

The OctaveEnvironment type exposes the following members.

Constructors
  NameDescription
Protected methodOctaveEnvironment
Initializes a new instance of the OctaveEnvironment class.
Top
Properties
  NameDescription
Protected property_
Matrix placeholder.
Protected propertyStatic memberUseOctaveDimensionIndexing
Whether to use octave indexing or not.
Top
Methods
  NameDescription
Protected methodStatic memberabs(Double)
Absolute value.
Protected methodStatic memberabs(Double)
Absolute value.
Protected methodStatic memberabs(Double)
Absolute value.
Protected methodStatic memberceil(Double)
Ceiling.
Protected methodStatic memberceil(Double)
Ceiling.
Protected methodStatic memberceil(Double)
Ceiling.
Protected methodStatic memberchol
Cholesky decomposition.
Protected methodStatic membercos(Double)
Cos.
Protected methodStatic membercos(Double)
Cos.
Protected methodStatic membercos(Double)
Cos.
Protected methodStatic membereig(Double, Double)
Eigenvalue decomposition.
Protected methodStatic membereig(Double, Double, Double)
Eigenvalue decomposition.
Protected methodStatic membereig(Double, Double, Double)
Eigenvalue decomposition.
Protected methodStatic membereig(Double, Double, Double, Double)
Eigenvalue decomposition.
Protected methodStatic membereig(Double, Double, Double, Double, Double)
Eigenvalue decomposition.
Protected methodStatic membereig(Double, Double, Double, Double, Double, Double, Double)
Eigenvalue decomposition.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodStatic memberexp(Double)
Exponential value.
Protected methodStatic memberexp(Double)
Exponential value.
Protected methodStatic memberexp(Double)
Exponential value.
Protected methodStatic membereye
Creates an identity matrix.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodStatic memberfloor(Double)
Flooring.
Protected methodStatic memberfloor(Double)
Flooring.
Protected methodStatic memberfloor(Double)
Flooring.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodStatic memberinv
Inverts a matrix.
Protected methodStatic memberlog(Double)
Logarithm.
Protected methodStatic memberlog(Double)
Logarithm.
Protected methodStatic memberlog(Double)
Logarithm.
Protected methodStatic membermagic
Creates a magic square matrix.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodStatic memberones(Int32)
Creates a unit matrix.
Protected methodStatic memberones(Int32, Int32)
Creates a unit matrix.
Protected methodStatic memberpinv
Inverts a matrix.
Protected methodStatic memberprod
Product of vector elements.
Protected methodStatic memberqr(Double, Double, Double)
QR decomposition.
Protected methodStatic memberqr(Double, Double, Double, Double)
QR decomposition.
Protected methodStatic memberrand
Random vector.
Protected methodStatic memberrank
Rank of a matrix.
Protected methodStatic memberround(Double)
Rounding.
Protected methodStatic memberround(Double)
Rounding.
Protected methodStatic memberround(Double)
Rounding.
Protected methodStatic membersin(Double)
Sin.
Protected methodStatic membersin(Double)
Sin.
Protected methodStatic membersin(Double)
Sin.
Protected methodStatic membersize
Size of a matrix.
Protected methodStatic membersum(Double)
Matrix sum vector.
Protected methodStatic membersum(Double)
Sum of vector elements.
Protected methodStatic membersum(Double, Int32)
Matrix sum vector.
Protected methodsvd
Singular value decomposition.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodStatic memberzeros(Int32)
Creates a unit matrix.
Protected methodStatic memberzeros(Int32, Int32)
Creates a unit matrix.
Top
Fields
  NameDescription
Protected fieldStatic membereps
Machine epsilon.
Protected fieldStatic memberpi
Pi.
Protected fieldret
Return setter keyword.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(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.)
Public Extension MethodToTOverloaded.
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.)
Top
Remarks

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:

Examples

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
See Also