Class DefaultMatrixFormatProvider
Gets the default matrix representation, where each row
is separated by a new line, and columns are separated by spaces.
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Numerics.Formats
Assembly: Mars.Numerics.dll
Syntax
public sealed class DefaultMatrixFormatProvider : MatrixFormatProviderBase, IMatrixFormatProvider, IFormatProvider
Remarks
This class can be used to convert to and from C#
matrices and their string representation. Please
see the example for details.
Examples
Converting from a multidimensional matrix to a string representation:
// Declare a number array
double[,] x =
{
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
};
// Convert the aforementioned array to a string representation:
string str = x.ToString(DefaultMatrixFormatProvider.CurrentCulture);
// the final result will be equivalent to
@"1, 2, 3, 4
5, 6, 7, 8";
Converting from strings to actual matrices:
// Declare an input string
string str = @"1, 2, 3, 4
"5, 6, 7, 8";
// Convert the string representation to an actual number array:
double[,] matrix = Matrix.Parse(str, DefaultMatrixFormatProvider.InvariantCulture);
// matrix will now contain the actual multidimensional
// matrix representation of the given string.
Constructors
| Improve this Doc View SourceDefaultMatrixFormatProvider(IFormatProvider)
Initializes a new instance of the DefaultMatrixFormatProvider class.
Declaration
public DefaultMatrixFormatProvider(IFormatProvider innerProvider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | innerProvider |
Remarks
This class can be used to convert to and from C#
matrices and their string representation. Please
see the example for details.
See Also
Properties
| Improve this Doc View SourceCurrentCulture
Gets the IMatrixFormatProvider which uses the CultureInfo used by the current thread.
Declaration
public static DefaultMatrixFormatProvider CurrentCulture { get; }
Property Value
Type | Description |
---|---|
DefaultMatrixFormatProvider |
Remarks
This class can be used to convert to and from C#
matrices and their string representation. Please
see the example for details.
See Also
| Improve this Doc View SourceInvariantCulture
Gets the IMatrixFormatProvider which uses the invariant system culture.
Declaration
public static DefaultMatrixFormatProvider InvariantCulture { get; }
Property Value
Type | Description |
---|---|
DefaultMatrixFormatProvider |
Remarks
This class can be used to convert to and from C#
matrices and their string representation. Please
see the example for details.
See Also
Implements
System.IFormatProvider