1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * https://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* 19 * This is not the original file distributed by the Apache Software Foundation 20 * It has been modified by the Hipparchus project 21 */ 22 23 package org.hipparchus.linear; 24 25 import org.hipparchus.exception.MathIllegalArgumentException; 26 27 /** 28 * This class defines a linear operator operating on real ({@code double}) 29 * vector spaces. No direct access to the coefficients of the underlying matrix 30 * is provided. 31 * <p> 32 * The motivation for such an interface is well stated by 33 * <a href="#BARR1994">Barrett et al. (1994)</a>: 34 * </p> 35 * <blockquote> 36 * We restrict ourselves to iterative methods, which work by repeatedly 37 * improving an approximate solution until it is accurate enough. These 38 * methods access the coefficient matrix A of the linear system only via the 39 * matrix-vector product y = A · x 40 * (and perhaps z = A<sup>T</sup> · x). Thus the user need only 41 * supply a subroutine for computing y (and perhaps z) given x, which permits 42 * full exploitation of the sparsity or other special structure of A. 43 * </blockquote> 44 * <dl> 45 * <dt>Barret et al. (1994)</dt> 46 * <dd> 47 * R. Barrett, M. Berry, T. F. Chan, J. Demmel, J. M. Donato, J. Dongarra, 48 * V. Eijkhout, R. Pozo, C. Romine and H. Van der Vorst, 49 * <em>Templates for the Solution of Linear Systems: Building Blocks for 50 * Iterative Methods</em>, SIAM 51 * </dd> 52 * </dl> 53 */ 54 public interface RealLinearOperator { 55 /** 56 * Returns the dimension of the codomain of this operator. 57 * 58 * @return the number of rows of the underlying matrix 59 */ 60 int getRowDimension(); 61 62 /** 63 * Returns the dimension of the domain of this operator. 64 * 65 * @return the number of columns of the underlying matrix 66 */ 67 int getColumnDimension(); 68 69 /** 70 * Returns the result of multiplying {@code this} by the vector {@code x}. 71 * 72 * @param x the vector to operate on 73 * @return the product of {@code this} instance with {@code x} 74 * @throws MathIllegalArgumentException if the column dimension does not match 75 * the size of {@code x} 76 */ 77 RealVector operate(RealVector x) 78 throws MathIllegalArgumentException; 79 80 /** 81 * Returns the result of multiplying the transpose of {@code this} operator 82 * by the vector {@code x} (optional operation). 83 * <p> 84 * The default implementation throws an {@link UnsupportedOperationException}. 85 * Users overriding this method must also override {@link #isTransposable()}. 86 * 87 * @param x the vector to operate on 88 * @return the product of the transpose of {@code this} instance with {@code x} 89 * @throws MathIllegalArgumentException if the row dimension does not match the 90 * size of {@code x} 91 * @throws UnsupportedOperationException if this operation is not supported 92 * by {@code this} operator 93 */ 94 default RealVector operateTranspose(final RealVector x) 95 throws MathIllegalArgumentException, UnsupportedOperationException { 96 throw new UnsupportedOperationException(); 97 } 98 99 /** 100 * Returns {@code true} if this operator supports {@link #operateTranspose(RealVector)}. 101 * <p> 102 * If {@code true} is returned, {@link #operateTranspose(RealVector)} 103 * should not throw {@code UnsupportedOperationException}. 104 * <p> 105 * The default implementation returns {@code false}. 106 * 107 * @return {@code false} 108 */ 109 default boolean isTransposable() { 110 return false; 111 } 112 }