Author: erans
Date: Tue Jul 12 21:34:34 2011
New Revision: 1145779
URL: http://svn.apache.org/viewvc?rev=1145779&view=rev
Log:
MATH-581
Framework for iterative solvers.
Added:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvertibleRealLinearOperator.java
(with props)
Added:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvertibleRealLinearOperator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvertibleRealLinearOperator.java?rev=1145779&view=auto
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvertibleRealLinearOperator.java
(added)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvertibleRealLinearOperator.java
Tue Jul 12 21:34:34 2011
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.linear;
+
+import org.apache.commons.math.exception.DimensionMismatchException;
+
+/**
+ * This interface defines a {@link RealLinearOperator} which can be inverted.
+ * Preconditioners typically fall into this category.
+ *
+ * @version $Id$
+ */
+public abstract class InvertibleRealLinearOperator extends RealLinearOperator {
+ /**
+ * Creates a new instance of this class with the specified dimension.
+ *
+ * @param dim Common dimension of the domain and codomain.
+ */
+ public InvertibleRealLinearOperator(final int dim) {
+ super(dim, dim);
+ }
+
+ /**
+ * Computes the matrix-vector product of the inverse of this instance
+ * with {@code b} and returns the result.
+ *
+ * @param b Right-hand side vector.
+ * @return the left-hand side vector.
+ */
+ public double[] solve(final double[] b) {
+ if (b.length != getRowDimension()) {
+ throw new DimensionMismatchException(b.length,
+ getRowDimension());
+ }
+ final RealVector x = solve(new ArrayRealVector(b, false));
+ if (x instanceof ArrayRealVector) {
+ return ((ArrayRealVector) x).getDataRef();
+ } else {
+ return x.getData();
+ }
+ }
+
+ /**
+ * Computes the matrix-vector product of the inverse of this instance
+ * with {@code b} and returns the result.
+ *
+ * @param b Right-hand side vector.
+ * @return the left-hand side vector.
+ */
+ public abstract RealVector solve(final RealVector b);
+}
Propchange:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/InvertibleRealLinearOperator.java
------------------------------------------------------------------------------
svn:eol-style = native