行列演算を行います。
public Matrix(int h, int w, long e) // e で初期化された h x w の行列
public Matrix(int h, int w) // 0 で初期化された h x w の行列
public Matrix(int n, long e) // e で初期化された h x n の正方行列
public Matrix(int n) // 0 で初期化された h x n の正方行列
public Matrix(final long[][] a) // 2次元配列をもとに行列を生成
public long get(int i, int j)
行目、 列目の要素を返します。
制約
計算量
public int getHeight()
行数を返します。
計算量
public int getWidth()
列数を返します。
計算量
public void set(int i, int j, long val)
行目、 列目に val を代入します。
制約
計算量
public Matrix copy()
自身のディープコピーを作成します。
計算量
public java.awt.Dimension shape()
行数と列数を java.awt.Dimension で返します
計算量
public Matrix mul(final Matrix other)
の行列積を計算します。
制約
計算量
public void modAsg(final int mod)
全ての要素の mod を取ります。
制約
計算量
public Matrix mulMod(final Matrix other, final int mod)
public Matrix mulMod(final Matrix other, final ModIntFactory factory)
の行列積の mod で割った余りを求めます。
⚠️ の各要素は mod が取られている前提です。 modAsg メソッドで予め mod を取っておいてください。
ModIntFactory を使うこともできます。
制約
計算量
public Matrix pow(long n)
正方行列の累乗を計算します。
制約
計算量
public Matrix powMod(long n, final int mod)
public Matrix powMod(long n, final ModIntFactory mod)
正方行列の累乗を mod で割った余りを求めます。
⚠️ 各要素は mod が取られている前提です。 modAsg メソッドで予め mod を取っておいてください。
ModIntFactory を使うこともできます。
制約
計算量