OgitaRumpOishiMethod.java

  1. /*
  2.  * Created on 2008/01/21
  3.  * Copyright (C) 2008 Koga Laboratory. All rights reserved.
  4.  *
  5.  */
  6. package org.mklab.cga.linear;

  7. import org.mklab.cga.interval.matrix.IntervalNumericalMatrix;
  8. import org.mklab.cga.interval.scalar.IntervalNumericalScalar;
  9. import org.mklab.nfc.matrix.NormType;
  10. import org.mklab.nfc.matrix.NumericalMatrix;
  11. import org.mklab.nfc.scalar.NumericalScalar;


  12. /**
  13.  * 線形方程式の精度保証付き解を(丸めの変更を行わない)Ogita-Rump-Oishiの方法で求めるクラスです。
  14.  *
  15.  * @author yano
  16.  * @version $Revision: 1.3 $, 2008/01/21
  17.  * @param <IS> 区間スカラーの型
  18.  * @param <IM> 区間行列の型
  19.  * @param <S> 成分の型
  20.  * @param <M> 行列の型
  21.  */
  22. public class OgitaRumpOishiMethod<IS extends IntervalNumericalScalar<IS,IM,S,M>, IM extends IntervalNumericalMatrix<IS,IM,S,M>, S extends NumericalScalar<S,M>, M extends NumericalMatrix<S,M>> implements LinearEquationVerifier<IS,IM,S,M> {

  23.   /** 係数行列 */
  24.   private M A;
  25.   /** 右辺係数ベクトル */
  26.   private M b;
  27.   /** 係数行列 */
  28.   private IM IA;
  29.   /** 右辺係数ベクトル */
  30.   private IM Ib;

  31.   /** 精度保証付き解 */
  32.   private IM solution;

  33.   /**
  34.    * 新しく生成された<code>OgitaMethod</code>オブジェクトを初期化します。
  35.    *
  36.    * @param A 係数行列
  37.    * @param b 右辺係数ベクトル
  38.    */
  39.   public OgitaRumpOishiMethod(final IM A, final IM b) {
  40.     this.IA = A;
  41.     this.Ib = b;
  42.   }


  43. //  /**
  44. //   * {@inheritDoc}
  45. //   */
  46. //  public void solve(IM A, M b) {
  47. //    throw new RuntimeException("Not implemented"); //$NON-NLS-1$
  48. //  }
  49. //
  50. //  /**
  51. //   * @see org.mklab.cga.linear.LinearEquationVerifier#solve(org.mklab.nfc.matrix.NumericalMatrix, org.mklab.cga.interval.matrix.IntervalMatrix)
  52. //   */
  53. //  public void solve(M A, IM b) {
  54. //    throw new RuntimeException("Not implemented"); //$NON-NLS-1$
  55. //  }
  56. //
  57. //  /**
  58. //   * @see org.mklab.cga.linear.LinearEquationVerifier#solve(org.mklab.nfc.matrix.NumericalMatrix, org.mklab.nfc.matrix.NumericalMatrix)
  59. //   */
  60. //  public void solve(M A, M b) {
  61. //    throw new RuntimeException("Not implemented"); //$NON-NLS-1$
  62. //  }

  63.   /**
  64.    * {@inheritDoc}
  65.    */
  66.   public void solve() {
  67.     //this.IA = IA;
  68.     this.A = this.IA.getMiddle();
  69.     //this.Ib = Ib;
  70.     this.b = this.Ib.getMiddle();

  71.     M R = this.A.inverse();
  72.     M xtilde = R.multiply(this.b);

  73.     M alpha = alphaStd(this.A, R);
  74.     M beta = beta(this.A, xtilde, this.b, R);
  75.     this.solution = null;
  76.   }

  77.   /**
  78.    * @see org.mklab.cga.linear.LinearEquationVerifier#getSolution()
  79.    */
  80.   public IM getSolution() {
  81.     return this.solution;
  82.   }

  83.   /**
  84.    * @param a a
  85.    * @param xtilde xtilde
  86.    * @param b b
  87.    * @param r r
  88.    * @return beta
  89.    */
  90.   private M beta(M a, M xtilde, M b, M r) {
  91.     return null;
  92.   }

  93.   /**
  94.    * @param A A
  95.    * @param R R
  96.    * @return alphaStd
  97.    */
  98.   private M alphaStd(M A, M R) {
  99.     S alpha1 = ((R.multiply(A).subtract((A.createUnit(A.getRowSize(), A.getColumnSize())))).norm(NormType.INFINITY));
  100.     if (alpha1.isGreaterThanOrEquals(1)) {
  101.       throw new RuntimeException("verification failed"); //$NON-NLS-1$
  102.     }
  103.     return null;
  104.   }
  105. }