RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
MatBuilder.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5package org.wpilib.math.linalg;
6
7import java.util.Objects;
8import org.ejml.simple.SimpleMatrix;
9import org.wpilib.math.util.Nat;
10import org.wpilib.math.util.Num;
11
13public final class MatBuilder {
14 private MatBuilder() {
15 throw new UnsupportedOperationException("This is a utility class!");
16 }
17
29 public static <R extends Num, C extends Num> Matrix<R, C> fill(
30 Nat<R> rows, Nat<C> cols, double... data) {
31 if (Objects.requireNonNull(data).length != rows.getNum() * cols.getNum()) {
32 throw new IllegalArgumentException(
33 "Invalid matrix data provided. Wanted "
34 + rows.getNum()
35 + " x "
36 + cols.getNum()
37 + " matrix, but got "
38 + data.length
39 + " elements");
40 }
41 return new Matrix<>(new SimpleMatrix(rows.getNum(), cols.getNum(), true, data));
42 }
43}
static< R extends Num, C extends Num > Matrix< R, C > fill(Nat< R > rows, Nat< C > cols, double... data)
Matrix(Nat< R > rows, Nat< C > columns)
Definition Matrix.java:46