@haxall/haxall
    Preparing search index...

    Class MatrixGrid

    MatrixGrid models a two dimensional grid of unitless Numbers. It wraps a Fantom math::Matrix instance.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a new grid with an additional column. The cells of the column are created by calling the mapping function for each row. The meta may be any value accepted by Etc.makeDict

      Parameters

      Returns Grid

    • Return a new grid with additional column meta-data. The new tags are merged according to Etc.dictMerge. The col parameter may be either a Col or column name. The meta may be any value accepted by Etc.makeDict. If column is not found then return this. Also see setColMeta.

      Parameters

      Returns Grid

    • Return a new grid by adding the given grid as a new set of columns to this grid. If the given grid contains duplicate column names, then they are given auto-generated unique names. If the given grid contains fewer rows then this grid, then the missing cells are filled with null.

      Parameters

      Returns Grid

    • Return a new grid with additional grid level meta-data. The new tags are merged according to Etc.dictMerge. The meta may be any value accepted by Etc.makeDict Also see setMeta.

      Parameters

      Returns Grid

    • Return true if the function returns true for all of the rows in the grid. If the grid is empty, return false.

      Parameters

      • f: (arg0: Row, arg1: number) => boolean

      Returns boolean

    • Return true if the function returns true for any of the rows in the grid. If the grid is empty, return false.

      Parameters

      • f: (arg0: Row, arg1: number) => boolean

      Returns boolean

    • Cofactor

      Returns MatrixGrid

    • Get a column by its name. If not resolved then return null or throw UnknownNameErr based on checked flag.

      Parameters

      • name: string
      • Optionalchecked: boolean

      Returns Col

    • Convenience for cols mapped to Col.dis. The resulting list is safe for mutating.

      Returns List<string>

    • Convenience for cols mapped to Col.name. The resulting list is safe for mutating.

      Returns List<string>

    • Columns

      Returns List<Col>

    • Get a column as a list of the cell values ordered by row.

      Parameters

      Returns List<JsObj>

    • Return a new Grid which is the result of applying the given diffs to this grid. The diffs must have the same number of rows as this grid. Any cells in the diffs with a Remove.val are removed from this grid, otherwise they are updated/added.

      Parameters

      Returns Grid

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Determinant

      Returns number

    • Iterate the rows

      Parameters

      • f: (arg0: Row, arg1: number) => void

      Returns void

    • Iterate every row until the function returns non-null. If function returns non-null, then break the iteration and return the resulting object. Return null if the function returns null for every item

      Parameters

      Returns JsObj

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Find one matching row or return null if no matches. Also see findIndex and findAll.

      Parameters

      • f: (arg0: Row, arg1: number) => boolean

      Returns Row

    • Return a new grid which finds matching the rows in this grid. The has the same meta and column definitions. Also see find and filter.

      Parameters

      • f: (arg0: Row, arg1: number) => boolean

      Returns Grid

    • Find one matching row index or return null if no matches. Also see find.

      Parameters

      • f: (arg0: Row, arg1: number) => boolean

      Returns number

    • Get the first row or return null if grid is empty.

      Returns Row

    • Return a new grid which maps each of the rows to zero or more new Dicts. The grid meta and existing column meta are maintained. New columns have empty meta.

      Parameters

      Returns Grid

    • Get floating point value for given cell in matrix

      Parameters

      • row: number
      • col: number

      Returns number

    • Get a row by its index number. Throw UnsupportedErr is the grid doesn't support indexed based row access.

      Parameters

      • index: number

      Returns Row

    • Return a new grid which is a slice of the rows in this grid. Negative indexes may be used to access from the end of the grid. The has the same meta and column definitions.

      Parameters

      Returns Grid

    • Get a row by its index number or if index is out of bounds then return null. Throw UnsupportedErr is the grid doesn't support indexed based row access.

      Parameters

      • index: number

      Returns Row

    • Return if this grid contains the given column name.

      Parameters

      • name: string

      Returns boolean

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • Insert column at leftmost position and fill with given value.

      Parameters

      • val: number

      Returns MatrixGrid

    • Inverse

      Returns MatrixGrid

    • Convenience for size equal to zero.

      Returns boolean

    • Return if this is an error grid - meta has "err" tag.

      Returns boolean

    • Return if this grid conforms to the history grid shape:

      • has at least two columns
      • first column is named "ts"
      • has meta hisStart and hisEnd DateTime values

      This method does not check timezones or the ts cells.

      Returns boolean

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Is this a square matrix where numRows == numCols

      Returns boolean

    • Join two grids by column name. The joinCol parameter may be a Col or col name. Current implementation requires:

      • grids cannot have conflicting col names (other than join col)
      • each row in both grids must have a unique value for join col
      • grid level meta is merged
      • join column meta is merged

      Parameters

      Returns Grid

    • Return a new grid with all the columns removed except the given columns. The toKeep columns can be Col instances or column names. Columns not found are silently ignored.

      Parameters

      Returns Grid

    • Get the last row or return null if grid is empty. Throw UnsupportedErr is the grid doesn't support indexed based row access.

      Returns Row

    • Return a new grid which maps the rows to new Dict. The grid meta and existing column meta are maintained. New columns have empty meta. If the mapping function returns null, then the row is removed.

      Parameters

      Returns Grid

    • Map each row to a list of values.

      Parameters

      Returns List<JsObj>

    • Meta-data for entire grid

      Returns Dict

    • Subtract two matrices together (must be of same dimension)

      Parameters

      Returns MatrixGrid

    • Return if this grid does not contains the given column name.

      Parameters

      • name: string

      Returns boolean

    • Multily each cell by given constant

      Parameters

      • x: number

      Returns MatrixGrid

    • Get Number value for given cell in matrix

      Parameters

      • row: number
      • col: number

      Returns Number

    • Number of cols in matrix

      Returns number

    • Number of rows in matrix

      Returns number

    • Add two matrices together (must be of same dimension)

      Parameters

      Returns MatrixGrid

    • Return a new grid with the given column removed. The col parameter may be either a Col or column name. If column doesn't exist return this grid.

      Parameters

      Returns Grid

    • Return a new grid with all the given columns removed. The toRemove columns can be Col instances or column names. Columns not found are silently ignored.

      Parameters

      Returns Grid

    • Return a new grid with the given column renamed. The oldCol parameter may be a Col or col name.

      Parameters

      • oldCol: JsObj
      • newName: string

      Returns Grid

    • Return a new grid with multiple columns renamed. The given map is keyed old column names and maps to new column names. Any column names not found are ignored.

      Parameters

      Returns Grid

    • Return a new grid with the columns reordered. The given list of names represents the new order and must contain the same current Col instances or column names. Any column names not found are ignored.

      Parameters

      Returns Grid

    • Replace every cell with the given from value with the to value. The resulting grid has the same grid and col meta. Replacement comparison is by via Fantom equality via == operator, so it will only replace scalar values or null.

      Parameters

      Returns Grid

    • Return new grid with column meta-data replaced by given meta. The col parameter may be either a Col or column name. The meta may be any value accepted by Etc.makeDict If column is not found then return this. Also see addColMeta.

      Parameters

      Returns Grid

    • Return a new grid with grid level meta-data replaced by given meta. The meta may be any value accepted by Etc.makeDict. Also see addMeta.

      Parameters

      Returns Grid

    • Get the number of rows in the grid. Throw UnsupportedErr if the grid doesn't support a size.

      Returns number

    • Return a new Grid which is a copy of this grid with the rows sorted by the given comparator function.

      Parameters

      • f: (arg0: Row, arg1: Row) => number

      Returns Grid

    • Convenience for sort which sorts the given column. The col parameter can be a Col or a str name. The sorting algorithm used is the same one used by the table UI based on the localized display string. If column is not found then return this.

      Parameters

      Returns Grid

    • Sort the given column in reverse. See sortCol

      Parameters

      Returns Grid

    • Return a new Grid which is a copy of this grid with the rows reverse sorted by the given comparator function.

      Parameters

      • f: (arg0: Row, arg1: Row) => number

      Returns Grid

    • Parameters

      • c: JsObj
      • Optionalchecked: boolean

      Returns Col

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Returns List<Row>

    • Return a string representation of this object.

      Returns string

    • Transpose

      Returns MatrixGrid

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • Return a new grid with only rows that define a unique key by the given key columns. If multiple rows have the same key cells, then the first row is returned and subsequent rows are removed. The keyCols can be Col instances or column names.

      Parameters

      Returns Grid

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Parameters

      • numRows: number
      • numCols: number

      Returns FloatArray

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Perform multiple linear regression using the 2 provided matrices. Y is expected to only have one column and it contains the dependent values. X will have as many columns as there are correlating factors. Y and X must have the same number of rows. X cannot have more columns that it has rows.

      Parameters

      Returns Grid

    • Parameters

      • numCols: number
      • row: number
      • col: number

      Returns number

    • Construct from a grid of Numbers. Columns are named "v0", "v1", etc. We maintain grid meta, but not column meta.

      Parameters

      • grid: Grid
      • Optionalopts: Dict
      • ...args: unknown[]

      Returns MatrixGrid