1 package org.djunits.value.vdouble.matrix; 2 3 import org.djunits.unit.AbsoluteLinearUnit; 4 import org.djunits.unit.Unit; 5 import org.djunits.value.StorageType; 6 import org.djunits.value.ValueException; 7 import org.djunits.value.vdouble.scalar.DoubleScalar; 8 9 /** 10 * Immutable DoubleMatrix. 11 * <p> 12 * This file was generated by the djunits value classes generator, 26 jun, 2015 13 * <p> 14 * Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 15 * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>. 16 * <p> 17 * $LastChangedDate: 2019-01-18 00:35:01 +0100 (Fri, 18 Jan 2019) $, @version $Revision: 324 $, by $Author: averbraeck $, 18 * initial version 26 jun, 2015 <br> 19 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 20 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 21 */ 22 public abstract class DoubleMatrix 23 { 24 /** 25 * ABSOLUTE implementation of DoubleMatrix. 26 * @param <AU> Absolute unit 27 * @param <RU> Relative unit 28 */ 29 public static class Abs<AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> extends AbstractDoubleMatrixAbs<AU, RU, 30 DoubleMatrix.Abs<AU, RU>, DoubleMatrix.Rel<RU>, MutableDoubleMatrix.Abs<AU, RU>, DoubleScalar.Abs<AU, RU>> 31 { 32 /** */ 33 private static final long serialVersionUID = 20151003L; 34 35 /** 36 * Construct a new Absolute Immutable DoubleMatrix. 37 * @param values double[][]; the values of the entries in the new Absolute Immutable DoubleMatrix 38 * @param unit AU; the unit of the new Absolute Immutable DoubleMatrix 39 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 40 * @throws ValueException when values is null 41 */ 42 public Abs(final double[][] values, final AU unit, final StorageType storageType) throws ValueException 43 { 44 super(values, unit, storageType); 45 } 46 47 /** 48 * Construct a new Absolute Immutable DoubleMatrix. 49 * @param values DoubleScalar.Abs<AU, RU>[][]; the values of the entries in the new Absolute Immutable 50 * DoubleMatrix 51 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 52 * @throws ValueException when values has zero entries 53 */ 54 public Abs(final DoubleScalar.Abs<AU, RU>[][] values, final StorageType storageType) throws ValueException 55 { 56 super(values, storageType); 57 } 58 59 /** 60 * Construct a new Absolute Immutable DoubleMatrix. 61 * @param data DoubleMatrixData; an internal data object 62 * @param unit AU; the unit 63 */ 64 Abs(final DoubleMatrixData data, final AU unit) 65 { 66 super(data, unit); 67 } 68 69 /** {@inheritDoc} */ 70 @Override 71 @SuppressWarnings("designforextension") 72 public DoubleMatrix.Abs<AU, RU> toDense() 73 { 74 return this.data.isDense() ? this : instantiateTypeAbs(this.data.toDense(), getUnit()); 75 } 76 77 /** {@inheritDoc} */ 78 @Override 79 @SuppressWarnings("designforextension") 80 public DoubleMatrix.Abs<AU, RU> toSparse() 81 { 82 return this.data.isSparse() ? this : instantiateTypeAbs(this.data.toSparse(), getUnit()); 83 } 84 85 /** {@inheritDoc} */ 86 @Override 87 protected final DoubleMatrix.Abs<AU, RU> instantiateTypeAbs(final DoubleMatrixData dmd, final AU unit) 88 { 89 return new DoubleMatrix.Abs<AU, RU>(dmd, unit); 90 } 91 92 /** {@inheritDoc} */ 93 @Override 94 protected final DoubleMatrix.Rel<RU> instantiateTypeRel(final DoubleMatrixData dmd, final RU unit) 95 { 96 return new DoubleMatrix.Rel<RU>(dmd, unit); 97 } 98 99 /** {@inheritDoc} */ 100 @Override 101 protected final MutableDoubleMatrix.Abs<AU, RU> instantiateMutableType(final DoubleMatrixData dmd, final AU unit) 102 { 103 return new MutableDoubleMatrix.Abs<AU, RU>(dmd, unit); 104 } 105 106 /** {@inheritDoc} */ 107 @Override 108 protected final DoubleScalar.Abs<AU, RU> instantiateScalar(final double value, final AU unit) 109 { 110 return new DoubleScalar.Abs<AU, RU>(value, unit); 111 } 112 } 113 114 /** 115 * RELATIVE implementation of DoubleMatrix. 116 * @param <U> Unit the unit for which this Matrix will be created 117 */ 118 public static class Rel<U extends Unit<U>> 119 extends AbstractDoubleMatrixRel<U, DoubleMatrix.Rel<U>, MutableDoubleMatrix.Rel<U>, DoubleScalar.Rel<U>> 120 121 { 122 /** */ 123 private static final long serialVersionUID = 20151003L; 124 125 /** 126 * Construct a new Relative Immutable DoubleMatrix. 127 * @param values double[][]; the values of the entries in the new Relative Immutable DoubleMatrix 128 * @param unit U; the unit of the new Relative Immutable DoubleMatrix 129 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 130 * @throws ValueException when values is null 131 */ 132 public Rel(final double[][] values, final U unit, final StorageType storageType) throws ValueException 133 { 134 super(values, unit, storageType); 135 } 136 137 /** 138 * Construct a new Relative Immutable DoubleMatrix. 139 * @param values DoubleScalar.Rel<U>[][]; the values of the entries in the new Relative Immutable DoubleMatrix 140 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 141 * @throws ValueException when values has zero entries 142 */ 143 public Rel(final DoubleScalar.Rel<U>[][] values, final StorageType storageType) throws ValueException 144 { 145 super(values, storageType); 146 } 147 148 /** 149 * Construct a new Relative Immutable DoubleMatrix. 150 * @param data DoubleMatrixData; an internal data object 151 * @param unit U; the unit 152 */ 153 Rel(final DoubleMatrixData data, final U unit) 154 { 155 super(data, unit); 156 } 157 158 /** {@inheritDoc} */ 159 @Override 160 @SuppressWarnings("designforextension") 161 public DoubleMatrix.Rel<U> toDense() 162 { 163 return this.data.isDense() ? this : instantiateType(this.data.toDense(), getUnit()); 164 } 165 166 /** {@inheritDoc} */ 167 @Override 168 @SuppressWarnings("designforextension") 169 public DoubleMatrix.Rel<U> toSparse() 170 { 171 return this.data.isSparse() ? this : instantiateType(this.data.toSparse(), getUnit()); 172 } 173 174 /** {@inheritDoc} */ 175 @Override 176 protected final DoubleMatrix.Rel<U> instantiateType(final DoubleMatrixData dmd, final U unit) 177 { 178 return new DoubleMatrix.Rel<U>(dmd, unit); 179 } 180 181 /** {@inheritDoc} */ 182 @Override 183 protected final MutableDoubleMatrix.Rel<U> instantiateMutableType(final DoubleMatrixData dmd, final U unit) 184 { 185 return new MutableDoubleMatrix.Rel<U>(dmd, unit); 186 } 187 188 /** {@inheritDoc} */ 189 @Override 190 protected final DoubleScalar.Rel<U> instantiateScalar(final double value, final U unit) 191 { 192 return new DoubleScalar.Rel<U>(value, unit); 193 } 194 } 195 196 /* ============================================================================================ */ 197 /* =========================== STATIC CALCULATION MATRIX METHODS ============================== */ 198 /* ============================================================================================ */ 199 200 /** 201 * Add the content of two matrices with a static method on a cell-by-cell basis; Abs + Rel = Abs. 202 * @param left DoubleMatrix.Abs<AU,RU>; the first matrix 203 * @param right DoubleMatrix.Rel<RU>; the second matrix 204 * @param <AU> the absolute unit 205 * @param <RU> the corresponding relative unit 206 * @return the sum of the two matrices 207 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 208 */ 209 static <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> DoubleMatrix.Abs<AU, RU> plus( 210 final DoubleMatrix.Abs<AU, RU> left, final DoubleMatrix.Rel<RU> right) throws ValueException 211 { 212 return left.mutable().plus(right); 213 } 214 215 /** 216 * Add the content of two matrices with a static method on a cell-by-cell basis; Rel + Rel = Rel. 217 * @param left DoubleMatrix.Rel<U>; the first matrix 218 * @param right DoubleMatrix.Rel<U>; the second matrix 219 * @param <U> the relative unit 220 * @return the sum of the two matrices 221 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 222 */ 223 static <U extends Unit<U>> DoubleMatrix.Rel<U> plus(final DoubleMatrix.Rel<U> left, final DoubleMatrix.Rel<U> right) 224 throws ValueException 225 { 226 return left.mutable().plus(right); 227 } 228 229 /** 230 * Subtract the content of two matrices with a static method on a cell-by-cell basis; Abs - Rel = Abs. 231 * @param left DoubleMatrix.Abs<AU,RU>; the first matrix 232 * @param right DoubleMatrix.Rel<RU>; the second matrix 233 * @param <AU> the absolute unit 234 * @param <RU> the corresponding relative unit 235 * @return the difference of the two matrices 236 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 237 */ 238 static <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> DoubleMatrix.Abs<AU, RU> minus( 239 final DoubleMatrix.Abs<AU, RU> left, final DoubleMatrix.Rel<RU> right) throws ValueException 240 { 241 return left.mutable().minus(right); 242 } 243 244 /** 245 * Subtract the content of two matrices with a static method on a cell-by-cell basis; Abs - Abs = Rel. 246 * @param left DoubleMatrix.Abs<AU,RU>; the first matrix 247 * @param right DoubleMatrix.Abs<AU,RU>; the second matrix 248 * @param <AU> the absolute unit 249 * @param <RU> the corresponding relative unit 250 * @return the difference of the two matrices 251 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 252 */ 253 static <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> DoubleMatrix.Rel<RU> minus( 254 final DoubleMatrix.Abs<AU, RU> left, final DoubleMatrix.Abs<AU, RU> right) throws ValueException 255 { 256 return left.mutable().minus(right); 257 } 258 259 /** 260 * Subtract the content of two matrices with a static method on a cell-by-cell basis; Rel - Rel = Rel. 261 * @param left DoubleMatrix.Rel<U>; the first matrix 262 * @param right DoubleMatrix.Rel<U>; the second matrix 263 * @param <U> the unit 264 * @return the difference of the two matrices 265 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 266 */ 267 static <U extends Unit<U>> DoubleMatrix.Rel<U> minus(final DoubleMatrix.Rel<U> left, final DoubleMatrix.Rel<U> right) 268 throws ValueException 269 { 270 return left.mutable().minus(right); 271 } 272 273 /** 274 * Multiply the content of two matrices with a static method on a cell-by-cell basis; Rel * Rel = Rel. The unit is not 275 * changed by this method. 276 * @param left DoubleMatrix.Rel<U>; the first matrix 277 * @param right DoubleMatrix.Rel<U>; the second matrix 278 * @param <U> the unit 279 * @return the cell-by-cell multiplication of the two matrices 280 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 281 */ 282 static <U extends Unit<U>> DoubleMatrix.Rel<U> times(final DoubleMatrix.Rel<U> left, final DoubleMatrix.Rel<U> right) 283 throws ValueException 284 { 285 return left.mutable().times(right); 286 } 287 288 /** 289 * Divide the content of two matrices with a static method on a cell-by-cell basis; Rel / Rel = Rel. The unit is not changed 290 * by this method. 291 * @param left DoubleMatrix.Rel<U>; the first matrix 292 * @param right DoubleMatrix.Rel<U>; the second matrix 293 * @param <U> the unit 294 * @return the cell-by-cell division of the two matrices 295 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 296 */ 297 static <U extends Unit<U>> DoubleMatrix.Rel<U> divide(final DoubleMatrix.Rel<U> left, final DoubleMatrix.Rel<U> right) 298 throws ValueException 299 { 300 return left.mutable().divide(right); 301 } 302 303 }