1 package org.djunits.value.vfloat.matrix; 2 3 import java.util.Collection; 4 5 import org.djunits.unit.LengthUnit; 6 import org.djunits.unit.PositionUnit; 7 import org.djunits.value.storage.StorageType; 8 import org.djunits.value.vfloat.matrix.base.FloatMatrixAbs; 9 import org.djunits.value.vfloat.matrix.base.FloatSparseValue; 10 import org.djunits.value.vfloat.matrix.data.FloatMatrixData; 11 import org.djunits.value.vfloat.scalar.FloatLength; 12 import org.djunits.value.vfloat.scalar.FloatPosition; 13 import org.djunits.value.vfloat.vector.FloatLengthVector; 14 import org.djunits.value.vfloat.vector.FloatPositionVector; 15 import org.djunits.value.vfloat.vector.data.FloatVectorData; 16 17 import jakarta.annotation.Generated; 18 19 /** 20 * Immutable FloatPosition Matrix. 21 * <p> 22 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 23 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 24 * </p> 25 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a> 26 * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a> 27 */ 28 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z") 29 public class FloatPositionMatrix extends FloatMatrixAbs<PositionUnit, FloatPosition, FloatPositionVector, FloatPositionMatrix, 30 LengthUnit, FloatLength, FloatLengthVector, FloatLengthMatrix> 31 { 32 /** */ 33 private static final long serialVersionUID = 20151006L; 34 35 /** 36 * Construct a PositionMatrix from an internal data object. 37 * @param data FloatMatrixData; the internal data object for the matrix 38 * @param displayUnit PositionUnit; the display unit of the matrix data 39 */ 40 public FloatPositionMatrix(final FloatMatrixData data, final PositionUnit displayUnit) 41 { 42 super(data, displayUnit); 43 } 44 45 /* CONSTRUCTORS WITH float[][] */ 46 47 /** 48 * Construct a FloatPositionMatrix from a float[][] object. The float values are expressed in the displayUnit, and will be 49 * printed using the displayUnit. 50 * @param data float[][]; the data for the matrix, expressed in the displayUnit 51 * @param displayUnit PositionUnit; the unit of the values in the data array, and display unit when printing 52 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix 53 */ 54 public FloatPositionMatrix(final float[][] data, final PositionUnit displayUnit, final StorageType storageType) 55 { 56 this(FloatMatrixData.instantiate(data, displayUnit.getScale(), storageType), displayUnit); 57 } 58 59 /** 60 * Construct a FloatPositionMatrix from a float[][] object. The float values are expressed in the displayUnit. Assume that 61 * the StorageType is DENSE since we offer the data as an array of an array. 62 * @param data float[][]; the data for the matrix 63 * @param displayUnit PositionUnit; the unit of the values in the data array, and display unit when printing 64 */ 65 public FloatPositionMatrix(final float[][] data, final PositionUnit displayUnit) 66 { 67 this(data, displayUnit, StorageType.DENSE); 68 } 69 70 /** 71 * Construct a FloatPositionMatrix from a float[][] object with SI-unit values. 72 * @param data float[][]; the data for the matrix, in SI units 73 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix 74 */ 75 public FloatPositionMatrix(final float[][] data, final StorageType storageType) 76 { 77 this(data, PositionUnit.BASE.getStandardUnit(), storageType); 78 } 79 80 /** 81 * Construct a FloatPositionMatrix from a float[][] object with SI-unit values. Assume that the StorageType is DENSE since 82 * we offer the data as an array of an array. 83 * @param data float[][]; the data for the matrix, in SI units 84 */ 85 public FloatPositionMatrix(final float[][] data) 86 { 87 this(data, StorageType.DENSE); 88 } 89 90 /* CONSTRUCTORS WITH FloatPosition[][] */ 91 92 /** 93 * Construct a FloatPositionMatrix from an array of an array of FloatPosition objects. The FloatPosition values are each 94 * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. 95 * @param data FloatPosition[][]; the data for the matrix 96 * @param displayUnit PositionUnit; the display unit of the values when printing 97 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix 98 */ 99 public FloatPositionMatrix(final FloatPosition[][] data, final PositionUnit displayUnit, final StorageType storageType) 100 { 101 this(FloatMatrixData.instantiate(data, storageType), displayUnit); 102 } 103 104 /** 105 * Construct a FloatPositionMatrix from an array of an array of FloatPosition objects. The FloatPosition values are each 106 * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. 107 * Assume that the StorageType is DENSE since we offer the data as an array of an array. 108 * @param data FloatPosition[][]; the data for the matrix 109 * @param displayUnit PositionUnit; the display unit of the values when printing 110 */ 111 public FloatPositionMatrix(final FloatPosition[][] data, final PositionUnit displayUnit) 112 { 113 this(data, displayUnit, StorageType.DENSE); 114 } 115 116 /** 117 * Construct a FloatPositionMatrix from an array of an array of FloatPosition objects. The FloatPosition values are each 118 * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing. 119 * since we offer the data as an array of an array. 120 * @param data FloatPosition[][]; the data for the matrix 121 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix 122 */ 123 public FloatPositionMatrix(final FloatPosition[][] data, final StorageType storageType) 124 { 125 this(data, PositionUnit.BASE.getStandardUnit(), storageType); 126 } 127 128 /** 129 * Construct a FloatPositionMatrix from an array of an array of FloatPosition objects. The FloatPosition values are each 130 * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing. 131 * Assume that the StorageType is DENSE since we offer the data as an array of an array. 132 * @param data FloatPosition[][]; the data for the matrix 133 */ 134 public FloatPositionMatrix(final FloatPosition[][] data) 135 { 136 this(data, StorageType.DENSE); 137 } 138 139 /* CONSTRUCTORS WITH Collection<FloatSparseValue> */ 140 141 /** 142 * Construct a FloatPositionMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates the 143 * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. 144 * @param data Collection<FloatSparseValue>; the data for the matrix 145 * @param displayUnit PositionUnit; the display unit of the matrix data, and the unit of the data points 146 * @param rows int; the number of rows of the matrix 147 * @param cols int; the number of columns of the matrix 148 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix 149 */ 150 public FloatPositionMatrix(final Collection<FloatSparseValue<PositionUnit, FloatPosition>> data, 151 final PositionUnit displayUnit, final int rows, final int cols, final StorageType storageType) 152 { 153 this(FloatMatrixData.instantiate(data, rows, cols, storageType), displayUnit); 154 } 155 156 /** 157 * Construct a FloatPositionMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates the 158 * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Assume the 159 * storage type is SPARSE, since we offer the data as a collection. 160 * @param data Collection<FloatSparseValue>; the data for the matrix 161 * @param displayUnit PositionUnit; the display unit of the matrix data, and the unit of the data points 162 * @param rows int; the number of rows of the matrix 163 * @param cols int; the number of columns of the matrix 164 */ 165 public FloatPositionMatrix(final Collection<FloatSparseValue<PositionUnit, FloatPosition>> data, 166 final PositionUnit displayUnit, final int rows, final int cols) 167 { 168 this(data, displayUnit, rows, cols, StorageType.SPARSE); 169 } 170 171 /** 172 * Construct a FloatPositionMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates the 173 * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Use the SI 174 * unit or base unit as the displayUnit. 175 * @param data Collection<FloatSparseValue>; the data for the matrix 176 * @param rows int; the number of rows of the matrix 177 * @param cols int; the number of columns of the matrix 178 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Matrix 179 */ 180 public FloatPositionMatrix(final Collection<FloatSparseValue<PositionUnit, FloatPosition>> data, final int rows, 181 final int cols, final StorageType storageType) 182 { 183 this(data, PositionUnit.BASE.getStandardUnit(), rows, cols, storageType); 184 } 185 186 /** 187 * Construct a FloatPositionMatrix from a (sparse) collection of FloatSparseValue objects. The displayUnit indicates the 188 * unit in which the values in the collection are expressed, as well as the unit in which they will be printed. Use the SI 189 * unit or base unit as the displayUnit. Assume the storage type is SPARSE, since we offer the data as a collection. 190 * @param data Collection<FloatSparseValue>; the data for the matrix 191 * @param rows int; the number of rows of the matrix 192 * @param cols int; the number of columns of the matrix 193 */ 194 public FloatPositionMatrix(final Collection<FloatSparseValue<PositionUnit, FloatPosition>> data, final int rows, 195 final int cols) 196 { 197 this(data, PositionUnit.BASE.getStandardUnit(), rows, cols, StorageType.SPARSE); 198 } 199 200 @Override 201 public Class<FloatPosition> getScalarClass() 202 { 203 return FloatPosition.class; 204 } 205 206 @Override 207 public Class<FloatPositionVector> getVectorClass() 208 { 209 return FloatPositionVector.class; 210 } 211 212 @Override 213 public FloatPositionMatrix instantiateMatrix(final FloatMatrixData fmd, final PositionUnit displayUnit) 214 { 215 return new FloatPositionMatrix(fmd, displayUnit); 216 } 217 218 @Override 219 public FloatPositionVector instantiateVector(final FloatVectorData fvd, final PositionUnit displayUnit) 220 { 221 return new FloatPositionVector(fvd, displayUnit); 222 } 223 224 @Override 225 public FloatPosition instantiateScalarSI(final float valueSI, final PositionUnit displayUnit) 226 { 227 FloatPosition result = FloatPosition.instantiateSI(valueSI); 228 result.setDisplayUnit(displayUnit); 229 return result; 230 } 231 232 @Override 233 public FloatLengthMatrix instantiateMatrixRel(final FloatMatrixData fmd, final LengthUnit displayUnit) 234 { 235 return new FloatLengthMatrix(fmd, displayUnit); 236 } 237 238 @Override 239 public FloatLengthVector instantiateVectorRel(final FloatVectorData fvd, final LengthUnit displayUnit) 240 { 241 return new FloatLengthVector(fvd, displayUnit); 242 } 243 244 @Override 245 public FloatLength instantiateScalarRelSI(final float valueSI, final LengthUnit displayUnit) 246 { 247 FloatLength result = FloatLength.instantiateSI(valueSI); 248 result.setDisplayUnit(displayUnit); 249 return result; 250 } 251 252 }