Class PhysicalValueComplex
- Namespace
- VirtualLabAPI.Core.Numerics
- Assembly
- VirtualLabAPI.dll
Class for a complex value with a physical unit.
[Serializable]
public class PhysicalValueComplex : PhysicalValueBase, IEquatable<IObjectBase>, ISerializable, IDeserializationCallback, ICloneable, IFormattable
- Inheritance
-
ObjectBaseSerializableObjectBaseManualSerializationPhysicalValueComplex
- Implements
-
IEquatable<IObjectBase>
- Inherited Members
Constructors
PhysicalValueComplex(Complex, MeasuredQuantity)
Default constructor
public PhysicalValueComplex(Complex value, MeasuredQuantity measuredQuantity)
Parameters
valueComplexThe value of the PhysicalValue.
measuredQuantityMeasuredQuantityThe measured quantity of the physical value (e.g. length).
PhysicalValueComplex(Complex, MeasuredQuantity, string)
Constructor with a comment string.
public PhysicalValueComplex(Complex value, MeasuredQuantity measuredQuantity, string comment)
Parameters
valueComplexThe value of the PhysicalValue.
measuredQuantityMeasuredQuantityThe measured quantity of the physical value (e.g. length).
commentstringA comment specifying what the PhysicalValue actually is.
Properties
Value
The value of the PhysicalValue.
public Complex Value { get; set; }
Property Value
Methods
Clone()
Creates a new object that is a copy of the current instance.
public override object Clone()
Returns
- object
A new object that is a copy of this instance.
Equals(object, EqualityIntent)
Overridden Equals functionality.
public override bool Equals(object obj, EqualityIntent equalityIntent)
Parameters
objobjectThe object to compare for equality.
equalityIntentEqualityIntentDefines what kind of equality you want to check when comparing two objects, for example all values or physical equality.
Returns
- bool
TRUE: The objects are equal. FALSE: The objects are not equal.
ExtractFieldQuantity(FieldQuantity)
Extracts the given field quantity.
public PhysicalValue ExtractFieldQuantity(FieldQuantity fieldQuantity)
Parameters
fieldQuantityFieldQuantityThe field quantity to extract.
Returns
- PhysicalValue
The given field quantity as double-valued PhysicalValue.
Exceptions
- NotImplementedException
Extraction of the given field quantity is not implemented.
ToString()
Overridden ToString function. The PhysicalValue is formatted like "1 nm".
public override string ToString()
Returns
- string
The formatted value.
ToString(int)
Overridden ToString function. The PhysicalValue is formatted like "1 nm".
public override string ToString(int significantDigits)
Parameters
significantDigitsintThe number of significant digits.
Returns
- string
The formatted value.
ToString(int, ComplexToStringConversionFormat)
Overridden ToString function. The PhysicalValue is formatted like "1 nm".
public string ToString(int significantDigits, ComplexToStringConversionFormat complexNumberRepresentation)
Parameters
significantDigitsintThe number of significant digits.
complexNumberRepresentationComplexToStringConversionFormatType of string conversion format.
Returns
- string
The formatted value.
ToString(string, IFormatProvider)
Overridden ToString function provided by the IFormattable interface. Returns a string that represents this instance.
public override string ToString(string format, IFormatProvider formatProvider = null)
Parameters
formatstringThe format. "U" or an empty string means that the string is formatted with units (e.g. "1 nm"). "G" means that the string is formatted without units (e.g. "1e-9"). "F" means that the string is formatted as "{Comment} of {Value with units}" (e.g. "wavelength of 300 nm").
In all cases you can add a number to specify the number of digits that shall be used. E.g. "U3" results in "1.23 nm", while "U4" results in "1.234 nm". You can add further formatting commands after a comma, but these are ignored. This behavior ensures that the same formatting strings can be used for both PhysicalValue and PhysicalValueComplex.
For any other string the ToString(format, formatProvider) of the Value is used.formatProviderIFormatProviderOptional culture specific format provider. Not used.
Returns
Operators
operator ==(PhysicalValueComplex, PhysicalValueComplex)
Compares two PhysicalValueComplex for equality. The comparison will be done by comparing the values, units, and comments, respectively.
public static bool operator ==(PhysicalValueComplex value1, PhysicalValueComplex value2)
Parameters
value1PhysicalValueComplexFirst PhysicalValueComplex object to compare.
value2PhysicalValueComplexSecond PhysicalValueComplex object to compare.
Returns
- bool
Returns true if the two objects are equal.
operator !=(PhysicalValueComplex, PhysicalValueComplex)
Compares two PhysicalValueComplex for inequality. The comparison will be done by comparing the values, units, and comments, respectively.
public static bool operator !=(PhysicalValueComplex value1, PhysicalValueComplex value2)
Parameters
value1PhysicalValueComplexFirst PhysicalValueComplex object to compare.
value2PhysicalValueComplexSecond PhysicalValueComplex object to compare.
Returns
- bool
Returns true if the two objects are unequal.