1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package eu.simuline.octave.type;
17
18 import eu.simuline.octave.type.matrix.AbstractGenericMatrix;
19
20 import eu.simuline.octave.util.StringUtil;
21
22 import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
23
24
25
26
27 public final class OctaveDouble
28 extends AbstractGenericMatrix<double[], DoubleArrayList> {
29
30
31
32
33
34
35
36
37 public OctaveDouble(final int... size) {
38 super(size);
39 }
40
41
42
43
44
45
46
47
48 public OctaveDouble(final double[] data, final int... size) {
49 super(data, size);
50 }
51
52
53
54
55
56
57
58 protected OctaveDoubleaveDouble.html#OctaveDouble">OctaveDouble(final OctaveDouble o) {
59 super(o);
60 }
61
62 protected final DoubleArrayList newL(final int size) {
63 DoubleArrayList list = new DoubleArrayList(size);
64 list.size(size);
65 return list;
66 }
67
68 protected final int initL(double[] data, final int size) {
69 this.dataL = new DoubleArrayList(data);
70 this.dataL.size(size);
71 return data.length;
72 }
73
74 protected double[] getDataA() {
75 return this.dataL.elements();
76 }
77
78
79
80
81
82
83
84
85
86 public final void set(final double value, final int... pos) {
87 resizeUp(pos);
88 setPlain(value, pos2ind(pos));
89 }
90
91
92
93
94
95
96
97
98 public final void setPlain(final double value, final int pos) {
99 this.dataL.set(pos, value);
100 }
101
102
103 public final void setPlain(final String value, final int pos) {
104 this.dataL.set(pos, StringUtil.parseDouble(value));
105 }
106
107
108
109
110
111
112
113 public final double get(final int... pos) {
114 return this.dataL.getDouble(pos2ind(pos));
115 }
116
117 public final String getPlainString(int pos) {
118 return Double.toString(this.dataL.getDouble(pos));
119 }
120
121
122 public OctaveDouble zero() {
123 return new OctaveDouble(this.size);
124 }
125
126
127 @Override
128 public OctaveDouble shallowCopy() {
129 return new OctaveDouble(this);
130 }
131
132 }