1 package org.djunits.value.vfloat.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.vfloat.scalar.FloatScalar; 8 9 /** 10 * Immutable FloatMatrix. 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 FloatMatrix 23 { 24 /** 25 * ABSOLUTE implementation of FloatMatrix. 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 AbstractFloatMatrixAbs<AU, RU, 30 FloatMatrix.Abs<AU, RU>, FloatMatrix.Rel<RU>, MutableFloatMatrix.Abs<AU, RU>, FloatScalar.Abs<AU, RU>> 31 { 32 /** */ 33 private static final long serialVersionUID = 20151003L; 34 35 /** 36 * Construct a new Absolute Immutable FloatMatrix. 37 * @param values float[][]; the values of the entries in the new Absolute Immutable FloatMatrix 38 * @param unit AU; the unit of the new Absolute Immutable FloatMatrix 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 float[][] values, final AU unit, final StorageType storageType) throws ValueException 43 { 44 super(values, unit, storageType); 45 } 46 47 /** 48 * Construct a new Absolute Immutable FloatMatrix. 49 * @param values FloatScalar.Abs<AU, RU>[][]; the values of the entries in the new Absolute Immutable FloatMatrix 50 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 51 * @throws ValueException when values has zero entries 52 */ 53 public Abs(final FloatScalar.Abs<AU, RU>[][] values, final StorageType storageType) throws ValueException 54 { 55 super(values, storageType); 56 } 57 58 /** 59 * Construct a new Absolute Immutable FloatMatrix. 60 * @param data FloatMatrixData; an internal data object 61 * @param unit AU; the unit 62 */ 63 Abs(final FloatMatrixData data, final AU unit) 64 { 65 super(data, unit); 66 } 67 68 /** {@inheritDoc} */ 69 @Override 70 @SuppressWarnings("designforextension") 71 public FloatMatrix.Abs<AU, RU> toDense() 72 { 73 return this.data.isDense() ? this : instantiateTypeAbs(this.data.toDense(), getUnit()); 74 } 75 76 /** {@inheritDoc} */ 77 @Override 78 @SuppressWarnings("designforextension") 79 public FloatMatrix.Abs<AU, RU> toSparse() 80 { 81 return this.data.isSparse() ? this : instantiateTypeAbs(this.data.toSparse(), getUnit()); 82 } 83 84 /** {@inheritDoc} */ 85 @Override 86 protected final FloatMatrix.Abs<AU, RU> instantiateTypeAbs(final FloatMatrixData dmd, final AU unit) 87 { 88 return new FloatMatrix.Abs<AU, RU>(dmd, unit); 89 } 90 91 /** {@inheritDoc} */ 92 @Override 93 protected final FloatMatrix.Rel<RU> instantiateTypeRel(final FloatMatrixData dmd, final RU unit) 94 { 95 return new FloatMatrix.Rel<RU>(dmd, unit); 96 } 97 98 /** {@inheritDoc} */ 99 @Override 100 protected final MutableFloatMatrix.Abs<AU, RU> instantiateMutableType(final FloatMatrixData dmd, final AU unit) 101 { 102 return new MutableFloatMatrix.Abs<AU, RU>(dmd, unit); 103 } 104 105 /** {@inheritDoc} */ 106 @Override 107 protected final FloatScalar.Abs<AU, RU> instantiateScalar(final float value, final AU unit) 108 { 109 return new FloatScalar.Abs<AU, RU>(value, unit); 110 } 111 } 112 113 /** 114 * RELATIVE implementation of FloatMatrix. 115 * @param <U> Unit the unit for which this Matrix will be created 116 */ 117 public static class Rel<U extends Unit<U>> 118 extends AbstractFloatMatrixRel<U, FloatMatrix.Rel<U>, MutableFloatMatrix.Rel<U>, FloatScalar.Rel<U>> 119 { 120 /** */ 121 private static final long serialVersionUID = 20151003L; 122 123 /** 124 * Construct a new Relative Immutable FloatMatrix. 125 * @param values float[][]; the values of the entries in the new Relative Immutable FloatMatrix 126 * @param unit U; the unit of the new Relative Immutable FloatMatrix 127 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 128 * @throws ValueException when values is null 129 */ 130 public Rel(final float[][] values, final U unit, final StorageType storageType) throws ValueException 131 { 132 super(values, unit, storageType); 133 } 134 135 /** 136 * Construct a new Relative Immutable FloatMatrix. 137 * @param values FloatScalar.Rel<U>[][]; the values of the entries in the new Relative Immutable FloatMatrix 138 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 139 * @throws ValueException when values has zero entries 140 */ 141 public Rel(final FloatScalar.Rel<U>[][] values, final StorageType storageType) throws ValueException 142 { 143 super(values, storageType); 144 } 145 146 /** 147 * Construct a new Relative Immutable FloatMatrix. 148 * @param data FloatMatrixData; an internal data object 149 * @param unit U; the unit 150 */ 151 Rel(final FloatMatrixData data, final U unit) 152 { 153 super(data, unit); 154 } 155 156 /** {@inheritDoc} */ 157 @Override 158 @SuppressWarnings("designforextension") 159 public FloatMatrix.Rel<U> toDense() 160 { 161 return this.data.isDense() ? this : instantiateType(this.data.toDense(), getUnit()); 162 } 163 164 /** {@inheritDoc} */ 165 @Override 166 @SuppressWarnings("designforextension") 167 public FloatMatrix.Rel<U> toSparse() 168 { 169 return this.data.isSparse() ? this : instantiateType(this.data.toSparse(), getUnit()); 170 } 171 172 /** {@inheritDoc} */ 173 @Override 174 protected final FloatMatrix.Rel<U> instantiateType(final FloatMatrixData dmd, final U unit) 175 { 176 return new FloatMatrix.Rel<U>(dmd, unit); 177 } 178 179 /** {@inheritDoc} */ 180 @Override 181 protected final MutableFloatMatrix.Rel<U> instantiateMutableType(final FloatMatrixData dmd, final U unit) 182 { 183 return new MutableFloatMatrix.Rel<U>(dmd, unit); 184 } 185 186 /** {@inheritDoc} */ 187 @Override 188 protected final FloatScalar.Rel<U> instantiateScalar(final float value, final U unit) 189 { 190 return new FloatScalar.Rel<U>(value, unit); 191 } 192 } 193 194 /* ============================================================================================ */ 195 /* =========================== STATIC CALCULATION MATRIX METHODS ============================== */ 196 /* ============================================================================================ */ 197 198 /** 199 * Add the content of two matrices with a static method on a cell-by-cell basis; Abs + Rel = Abs. 200 * @param left FloatMatrix.Abs<AU,RU>; the first matrix 201 * @param right FloatMatrix.Rel<RU>; the second matrix 202 * @param <AU> the absolute unit 203 * @param <RU> the corresponding relative unit 204 * @return the sum of the two matrices 205 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 206 */ 207 static <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> FloatMatrix.Abs<AU, RU> plus( 208 final FloatMatrix.Abs<AU, RU> left, final FloatMatrix.Rel<RU> right) throws ValueException 209 { 210 return left.mutable().plus(right); 211 } 212 213 /** 214 * Add the content of two matrices with a static method on a cell-by-cell basis; Rel + Rel = Rel. 215 * @param left FloatMatrix.Rel<U>; the first matrix 216 * @param right FloatMatrix.Rel<U>; the second matrix 217 * @param <U> the relative unit 218 * @return the sum of the two matrices 219 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 220 */ 221 static <U extends Unit<U>> FloatMatrix.Rel<U> plus(final FloatMatrix.Rel<U> left, final FloatMatrix.Rel<U> right) 222 throws ValueException 223 { 224 return left.mutable().plus(right); 225 } 226 227 /** 228 * Subtract the content of two matrices with a static method on a cell-by-cell basis; Abs - Rel = Abs. 229 * @param left FloatMatrix.Abs<AU,RU>; the first matrix 230 * @param right FloatMatrix.Rel<RU>; the second matrix 231 * @param <AU> the absolute unit 232 * @param <RU> the corresponding relative unit 233 * @return the difference of the two matrices 234 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 235 */ 236 static <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> FloatMatrix.Abs<AU, RU> minus( 237 final FloatMatrix.Abs<AU, RU> left, final FloatMatrix.Rel<RU> right) throws ValueException 238 { 239 return left.mutable().minus(right); 240 } 241 242 /** 243 * Subtract the content of two matrices with a static method on a cell-by-cell basis; Abs - Abs = Rel. 244 * @param left FloatMatrix.Abs<AU,RU>; the first matrix 245 * @param right FloatMatrix.Abs<AU,RU>; the second matrix 246 * @param <AU> the absolute unit 247 * @param <RU> the corresponding relative unit 248 * @return the difference of the two matrices 249 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 250 */ 251 static <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>> FloatMatrix.Rel<RU> minus( 252 final FloatMatrix.Abs<AU, RU> left, final FloatMatrix.Abs<AU, RU> right) throws ValueException 253 { 254 return left.mutable().minus(right); 255 } 256 257 /** 258 * Subtract the content of two matrices with a static method on a cell-by-cell basis; Rel - Rel = Rel. 259 * @param left FloatMatrix.Rel<U>; the first matrix 260 * @param right FloatMatrix.Rel<U>; the second matrix 261 * @param <U> the unit 262 * @return the difference of the two matrices 263 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 264 */ 265 static <U extends Unit<U>> FloatMatrix.Rel<U> minus(final FloatMatrix.Rel<U> left, final FloatMatrix.Rel<U> right) 266 throws ValueException 267 { 268 return left.mutable().minus(right); 269 } 270 271 /** 272 * Multiply the content of two matrices with a static method on a cell-by-cell basis; Rel * Rel = Rel. The unit is not 273 * changed by this method. 274 * @param left FloatMatrix.Rel<U>; the first matrix 275 * @param right FloatMatrix.Rel<U>; the second matrix 276 * @param <U> the unit 277 * @return the cell-by-cell multiplication of the two matrices 278 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 279 */ 280 static <U extends Unit<U>> FloatMatrix.Rel<U> times(final FloatMatrix.Rel<U> left, final FloatMatrix.Rel<U> right) 281 throws ValueException 282 { 283 return left.mutable().times(right); 284 } 285 286 /** 287 * Divide the content of two matrices with a static method on a cell-by-cell basis; Rel / Rel = Rel. The unit is not changed 288 * by this method. 289 * @param left FloatMatrix.Rel<U>; the first matrix 290 * @param right FloatMatrix.Rel<U>; the second matrix 291 * @param <U> the unit 292 * @return the cell-by-cell division of the two matrices 293 * @throws ValueException when the two matrices have unequal size, or when one of the matrices is null or not well-formed 294 */ 295 static <U extends Unit<U>> FloatMatrix.Rel<U> divide(final FloatMatrix.Rel<U> left, final FloatMatrix.Rel<U> right) 296 throws ValueException 297 { 298 return left.mutable().divide(right); 299 } 300 301 }