Package linalg.util
Class Parser
java.lang.Object
linalg.util.Parser
Parser for complex number strings or matrix shape strings.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
parseNumber(String num)
Parses a complex number in the form of a string into its real and imaginary parts.static int[]
parseShape(String shape)
Parses Matrix shape in the form of 'mxn' where m is the number of rows and n is the number of columns.
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
parseShape
Parses Matrix shape in the form of 'mxn' where m is the number of rows and n is the number of columns.- Parameters:
shape
- - dimensions of matrix (rows by columns) in the form of a string.- Returns:
- A double array of length two containing the number of rows and columns respectively
-
parseNumber
Parses a complex number in the form of a string into its real and imaginary parts. For example, the string"2+3i"
would be parsed into real and imaginary parts2
and3
respectivly- Parameters:
num
- - complex number in one of three forms:a + bi, a,
orbi
where a and b are real numbers and i is the imaginary unit sqrt(-1)- Returns:
- A double array of length two containing the real and imaginary parts of num respectively
-