Package linalg.util

Class Parser

java.lang.Object
linalg.util.Parser

public class Parser extends Object
Parser for complex number strings or matrix shape strings.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Parser

      public Parser()
  • Method Details

    • parseShape

      public 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.
      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

      public static double[] parseNumber(String num)
      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 parts 2 and 3 respectivly
      Parameters:
      num - - complex number in one of three forms: a + bi, a, or bi 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