私はBreezeを使って一次方程式の均質系を解こうとします。私は非自明な解決策Breezeで一次方程式の均質系を解く方法
を取得したい
アックス= 0
はしかし、私は何をすべき非自明な解決策に
を見つけることにいくつかの問題を得ましたか。
おかげ
これは私のコードです:
val A =DenseMatrix(
(1.0,2.0,3.0,2.0),
(1.0,3.0,5.0,5.0),
(2.0,4.0,7.0,1.0),
(-1.0,-2.0,-6.0,-7.0)
)
val e = DenseVector(0,0,0,0)
val x = A \ e
エラー:すべての
breeze.linalg.MatrixSingularException:
at breeze.linalg.operators.DenseMatrixMultiplyStuff$implOpSolveMatrixBy_DMD_DMD_eq_DMD$.LUSolve(DenseMatrixOps.scala:151)
at breeze.linalg.operators.DenseMatrixMultiplyStuff$implOpSolveMatrixBy_DMD_DMD_eq_DMD$.apply(DenseMatrixOps.scala:127)
at breeze.linalg.operators.DenseMatrixMultiplyStuff$implOpSolveMatrixBy_DMD_DMD_eq_DMD$.apply(DenseMatrixOps.scala:115)
at breeze.linalg.ImmutableNumericOps$class.$bslash(NumericOps.scala:144)
at breeze.linalg.DenseMatrix.$bslash(DenseMatrix.scala:53)
at breeze.linalg.operators.DenseMatrixMultiplyStuff$implOpSolveMatrixBy_DMD_DVD_eq_DVD$.apply(DenseMatrixOps.scala:221)
at breeze.linalg.operators.DenseMatrixMultiplyStuff$implOpSolveMatrixBy_DMD_DVD_eq_DVD$.apply(DenseMatrixOps.scala:218)
at breeze.linalg.ImmutableNumericOps$class.$bslash(NumericOps.scala:144)
at breeze.linalg.DenseMatrix.$bslash(DenseMatrix.scala:53)
at .<init>(<console>:27)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:734)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:983)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:604)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:568)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:760)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:805)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:717)
at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:581)
at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:588)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:591)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:882)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:837)
at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:837)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:904)
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
あなたのマトリックスはフルランクです(*すべて*固有値はゼロではありません)。これは、その零空間(0ベクトルにマッピングされる入力空間の部分空間)が0ベクトルのみからなることを意味する。なぜBreezeが特異行列例外を投げているのか分かりませんが、文字通り 'Ax = 0'のような非ゼロベクトル' x'はありません。 –
@AhmedFasih私は別の例を試しました。それは単純な解(すべてゼロ)を返すだけです。一般的に、私はBreezeで自明ではない解決策を得ることができますか?またはサンプルの例を教えてもらえますか?ありがとう –
私はhttps://gist.github.com/fasiha/84c17532528b0274557ee2150df7e98dで 'Ax = 0'の解決策を見つける方法に関するいくつかの一般的なコメントを書いた。私はここでMatlabを使ったが、同じ原則はScipy/PythonとJulia and R 。:あなたはSVDを使用しています。私はScalaやBreezeがどのように動作するのか分かりませんが、SVDを使うことができれば、Ax = 0に非ゼロ解を得ることができます(Aがランク不足の場合)。 –