Class VariableBlock

java.lang.Object
org.wpilib.math.autodiff.VariableBlock
All Implemented Interfaces:
Iterable<Variable>

public class VariableBlock extends Object implements Iterable<Variable>
A submatrix of autodiff variables with reference semantics.
  • Constructor Details

    • VariableBlock

      Constructs a Variable block pointing to all of the given matrix.
      Parameters:
      mat - The matrix to which to point.
    • VariableBlock

      public VariableBlock(VariableMatrix mat, int rowOffset, int colOffset, int blockRows, int blockCols)
      Constructs a Variable block pointing to a subset of the given matrix.
      Parameters:
      mat - The matrix to which to point.
      rowOffset - The block's row offset.
      colOffset - The block's column offset.
      blockRows - The number of rows in the block.
      blockCols - The number of columns in the block.
    • VariableBlock

      public VariableBlock(VariableMatrix mat, Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
      Constructs a Variable block pointing to a subset of the given matrix.

      Note that the slices are taken as is rather than adjusted.

      Parameters:
      mat - The matrix to which to point.
      rowSlice - The block's row slice.
      rowSliceLength - The block's row length.
      colSlice - The block's column slice.
      colSliceLength - The block's column length.
  • Method Details

    • set

      public VariableBlock set(double value)
      Assigns a double to the block.

      This only works for blocks with one row and one column.

      Parameters:
      value - Value to assign.
      Returns:
      This VariableBlock.
    • set

      public VariableBlock set(Variable value)
      Assigns a Variable to the block.

      This only works for blocks with one row and one column.

      Parameters:
      value - Value to assign.
      Returns:
      This VariableBlock.
    • set

      public VariableBlock set(double[][] values)
      Assigns a double array to the block.
      Parameters:
      values - Double array of values to assign.
      Returns:
      This VariableBlock.
    • set

      public VariableBlock set(org.ejml.simple.SimpleMatrix values)
      Assigns an EJML matrix to the block.
      Parameters:
      values - EJML matrix of values to assign.
      Returns:
      This VariableBlock.
    • set

      public VariableBlock set(VariableMatrix values)
      Assigns a VariableMatrix to the block.
      Parameters:
      values - VariableMatrix of values.
      Returns:
      This VariableBlock.
    • set

      public VariableBlock set(VariableBlock values)
      Assigns a VariableBlock to the block.
      Parameters:
      values - VariableBlock of values.
      Returns:
      This VariableBlock.
    • set

      public void set(int row, int col, Variable value)
      Sets a scalar subblock at the given row and column.
      Parameters:
      row - The scalar subblock's row.
      col - The scalar subblock's column.
      value - The value.
    • set

      public void set(int row, int col, double value)
      Sets a scalar subblock at the given row and column.
      Parameters:
      row - The scalar subblock's row.
      col - The scalar subblock's column.
      value - The value.
    • set

      public void set(int index, double value)
      Sets a scalar subblock at the given index.
      Parameters:
      index - The scalar subblock's index.
      value - The value.
    • set

      public void set(int index, Variable value)
      Sets a scalar subblock at the given index.
      Parameters:
      index - The scalar subblock's index.
      value - The value.
    • setValue

      public void setValue(double value)
      Assigns a double to the block.

      This only works for blocks with one row and one column.

      Parameters:
      value - Value to assign.
    • setValue

      public void setValue(double[][] values)
      Sets block's internal values.
      Parameters:
      values - Double array of values.
    • setValue

      public void setValue(org.ejml.simple.SimpleMatrix values)
      Sets block's internal values.
      Parameters:
      values - EJML matrix of values.
    • get

      public Variable get(int row, int col)
      Returns a scalar subblock at the given row and column.
      Parameters:
      row - The scalar subblock's row.
      col - The scalar subblock's column.
      Returns:
      A scalar subblock at the given row and column.
    • get

      public Variable get(int index)
      Returns a scalar subblock at the given index.
      Parameters:
      index - The scalar subblock's index.
      Returns:
      A scalar subblock at the given index.
    • get

      public VariableBlock get(int row, Slice.None colSlice)
      Returns a slice of the variable matrix.
      Parameters:
      row - The row.
      colSlice - The column slice.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(int row, Slice colSlice)
      Returns a slice of the variable matrix.
      Parameters:
      row - The row.
      colSlice - The column slice.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(Slice.None rowSlice, int col)
      Returns a slice of the variable matrix.
      Parameters:
      rowSlice - The row slice.
      col - The column.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(Slice rowSlice, int col)
      Returns a slice of the variable matrix.
      Parameters:
      rowSlice - The row slice.
      col - The column.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(Slice.None rowSlice, Slice.None colSlice)
      Returns a slice of the variable matrix.
      Parameters:
      rowSlice - The row slice.
      colSlice - The column slice.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(Slice.None rowSlice, Slice colSlice)
      Returns a slice of the variable matrix.
      Parameters:
      rowSlice - The row slice.
      colSlice - The column slice.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(Slice rowSlice, Slice.None colSlice)
      Returns a slice of the variable matrix.
      Parameters:
      rowSlice - The row slice.
      colSlice - The column slice.
      Returns:
      A slice of the variable matrix.
    • get

      public VariableBlock get(Slice rowSlice, Slice colSlice)
      Returns a slice of the variable matrix.
      Parameters:
      rowSlice - The row slice.
      colSlice - The column slice.
      Returns:
      A slice of the variable matrix.
    • block

      public VariableBlock block(int rowOffset, int colOffset, int blockRows, int blockCols)
      Returns a block of the variable matrix.
      Parameters:
      rowOffset - The row offset of the block selection.
      colOffset - The column offset of the block selection.
      blockRows - The number of rows in the block selection.
      blockCols - The number of columns in the block selection.
      Returns:
      A block of the variable matrix.
    • segment

      public VariableBlock segment(int offset, int length)
      Returns a segment of the variable vector.
      Parameters:
      offset - The offset of the segment.
      length - The length of the segment.
      Returns:
      A segment of the variable vector.
    • row

      public VariableBlock row(int row)
      Returns a row slice of the variable matrix.
      Parameters:
      row - The row to slice.
      Returns:
      A row slice of the variable matrix.
    • col

      public VariableBlock col(int col)
      Returns a column slice of the variable matrix.
      Parameters:
      col - The column to slice.
      Returns:
      A column slice of the variable matrix.
    • times

      Matrix multiplication operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of matrix multiplication.
    • times

      Matrix multiplication operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of matrix multiplication.
    • times

      public VariableMatrix times(double rhs)
      Matrix-scalar multiplication operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of matrix-scalar multiplication.
    • times

      Matrix-scalar multiplication operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of matrix-scalar multiplication.
    • div

      public VariableMatrix div(double rhs)
      Binary division operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of division.
    • div

      public VariableMatrix div(Variable rhs)
      Binary division operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of division.
    • plus

      Binary addition operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of addition.
    • plus

      Binary addition operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of addition.
    • plus

      public VariableMatrix plus(org.ejml.simple.SimpleMatrix rhs)
      Binary addition operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of addition.
    • minus

      Binary subtraction operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of subtraction.
    • minus

      Binary subtraction operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of subtraction.
    • minus

      public VariableMatrix minus(org.ejml.simple.SimpleMatrix rhs)
      Binary subtraction operator.
      Parameters:
      rhs - Operator right-hand side.
      Returns:
      Result of subtraction.
    • unaryMinus

      Unary minus operator.
      Returns:
      Result of unary minus.
    • T

      public VariableMatrix T()
      Returns the transpose of the variable matrix.
      Returns:
      The transpose of the variable matrix.
    • rows

      public int rows()
      Returns the number of rows in the matrix.
      Returns:
      The number of rows in the matrix.
    • cols

      public int cols()
      Returns the number of columns in the matrix.
      Returns:
      The number of columns in the matrix.
    • value

      public double value(int row, int col)
      Returns an element of the variable matrix.
      Parameters:
      row - The row of the element to return.
      col - The column of the element to return.
      Returns:
      An element of the variable matrix.
    • value

      public double value(int index)
      Returns an element of the variable block.
      Parameters:
      index - The index of the element to return.
      Returns:
      An element of the variable block.
    • value

      public org.ejml.simple.SimpleMatrix value()
      Returns the contents of the variable matrix.
      Returns:
      The contents of the variable matrix.
    • cwiseMap

      Maps the matrix coefficient-wise with an unary operator.
      Parameters:
      unaryOp - The unary operator to use for the map operation.
      Returns:
      Result of the unary operator.
    • size

      public int size()
      Returns number of elements in matrix.
      Returns:
      Number of elements in matrix.
    • iterator

      Specified by:
      iterator in interface Iterable<Variable>
    • stream

      public Stream<Variable> stream()
      Creates a Stream of VariableBlock elements.
      Returns:
      A Stream of VariableBlock elements.