1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.hipparchus.linear;
24
25 import java.util.Iterator;
26 import java.util.NoSuchElementException;
27
28 import org.hipparchus.analysis.FunctionUtils;
29 import org.hipparchus.analysis.UnivariateFunction;
30 import org.hipparchus.analysis.function.Add;
31 import org.hipparchus.analysis.function.Divide;
32 import org.hipparchus.analysis.function.Multiply;
33 import org.hipparchus.exception.LocalizedCoreFormats;
34 import org.hipparchus.exception.MathIllegalArgumentException;
35 import org.hipparchus.exception.MathRuntimeException;
36 import org.hipparchus.util.FastMath;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public abstract class RealVector {
60
61
62
63
64
65
66
67
68 public RealVector() {
69
70 }
71
72
73
74
75
76
77 public abstract int getDimension();
78
79
80
81
82
83
84
85
86
87 public abstract double getEntry(int index) throws MathIllegalArgumentException;
88
89
90
91
92
93
94
95
96
97 public abstract void setEntry(int index, double value)
98 throws MathIllegalArgumentException;
99
100
101
102
103
104
105
106
107 public void addToEntry(int index, double increment)
108 throws MathIllegalArgumentException {
109 setEntry(index, getEntry(index) + increment);
110 }
111
112
113
114
115
116
117
118 public abstract RealVector append(RealVector v);
119
120
121
122
123
124
125
126 public abstract RealVector append(double d);
127
128
129
130
131
132
133
134
135
136
137 public abstract RealVector getSubVector(int index, int n)
138 throws MathIllegalArgumentException;
139
140
141
142
143
144
145
146
147 public abstract void setSubVector(int index, RealVector v)
148 throws MathIllegalArgumentException;
149
150
151
152
153
154
155
156 public abstract boolean isNaN();
157
158
159
160
161
162
163
164 public abstract boolean isInfinite();
165
166
167
168
169
170
171
172
173 protected void checkVectorDimensions(RealVector v)
174 throws MathIllegalArgumentException {
175 checkVectorDimensions(v.getDimension());
176 }
177
178
179
180
181
182
183
184
185 protected void checkVectorDimensions(int n)
186 throws MathIllegalArgumentException {
187 int d = getDimension();
188 if (d != n) {
189 throw new MathIllegalArgumentException(LocalizedCoreFormats.DIMENSIONS_MISMATCH,
190 d, n);
191 }
192 }
193
194
195
196
197
198
199
200 protected void checkIndex(final int index) throws MathIllegalArgumentException {
201 if (index < 0 ||
202 index >= getDimension()) {
203 throw new MathIllegalArgumentException(LocalizedCoreFormats.INDEX,
204 index, 0, getDimension() - 1);
205 }
206 }
207
208
209
210
211
212
213
214
215
216 protected void checkIndices(final int start, final int end)
217 throws MathIllegalArgumentException {
218 final int dim = getDimension();
219 if ((start < 0) || (start >= dim)) {
220 throw new MathIllegalArgumentException(LocalizedCoreFormats.INDEX, start, 0,
221 dim - 1);
222 }
223 if ((end < 0) || (end >= dim)) {
224 throw new MathIllegalArgumentException(LocalizedCoreFormats.INDEX, end, 0,
225 dim - 1);
226 }
227 if (end < start) {
228
229 throw new MathIllegalArgumentException(LocalizedCoreFormats.INITIAL_ROW_AFTER_FINAL_ROW,
230 end, start, false);
231 }
232 }
233
234
235
236
237
238
239
240
241
242
243 public RealVector add(RealVector v) throws MathIllegalArgumentException {
244 checkVectorDimensions(v);
245 RealVector result = v.copy();
246 Iterator<Entry> it = iterator();
247 while (it.hasNext()) {
248 final Entry e = it.next();
249 final int index = e.getIndex();
250 result.setEntry(index, e.getValue() + result.getEntry(index));
251 }
252 return result;
253 }
254
255
256
257
258
259
260
261
262
263
264 public RealVector subtract(RealVector v) throws MathIllegalArgumentException {
265 checkVectorDimensions(v);
266 RealVector result = v.mapMultiply(-1d);
267 Iterator<Entry> it = iterator();
268 while (it.hasNext()) {
269 final Entry e = it.next();
270 final int index = e.getIndex();
271 result.setEntry(index, e.getValue() + result.getEntry(index));
272 }
273 return result;
274 }
275
276
277
278
279
280
281
282
283 public RealVector mapAdd(double d) {
284 return copy().mapAddToSelf(d);
285 }
286
287
288
289
290
291
292
293
294 public RealVector mapAddToSelf(double d) {
295 if (d != 0) {
296 return mapToSelf(FunctionUtils.fix2ndArgument(new Add(), d));
297 }
298 return this;
299 }
300
301
302
303
304
305
306 public abstract RealVector copy();
307
308
309
310
311
312
313
314
315
316 public double dotProduct(RealVector v) throws MathIllegalArgumentException {
317 checkVectorDimensions(v);
318 double d = 0;
319 final int n = getDimension();
320 for (int i = 0; i < n; i++) {
321 d += getEntry(i) * v.getEntry(i);
322 }
323 return d;
324 }
325
326
327
328
329
330
331
332
333
334
335
336
337 public double cosine(RealVector v) throws MathIllegalArgumentException,
338 MathRuntimeException {
339 final double norm = getNorm();
340 final double vNorm = v.getNorm();
341
342 if (norm == 0 ||
343 vNorm == 0) {
344 throw new MathRuntimeException(LocalizedCoreFormats.ZERO_NORM);
345 }
346 return dotProduct(v) / (norm * vNorm);
347 }
348
349
350
351
352
353
354
355
356
357 public abstract RealVector ebeDivide(RealVector v)
358 throws MathIllegalArgumentException;
359
360
361
362
363
364
365
366
367
368 public abstract RealVector ebeMultiply(RealVector v)
369 throws MathIllegalArgumentException;
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385 public double getDistance(RealVector v) throws MathIllegalArgumentException {
386 checkVectorDimensions(v);
387 double d = 0;
388 Iterator<Entry> it = iterator();
389 while (it.hasNext()) {
390 final Entry e = it.next();
391 final double diff = e.getValue() - v.getEntry(e.getIndex());
392 d += diff * diff;
393 }
394 return FastMath.sqrt(d);
395 }
396
397
398
399
400
401
402
403
404
405
406
407 public double getNorm() {
408 double sum = 0;
409 Iterator<Entry> it = iterator();
410 while (it.hasNext()) {
411 final Entry e = it.next();
412 final double value = e.getValue();
413 sum += value * value;
414 }
415 return FastMath.sqrt(sum);
416 }
417
418
419
420
421
422
423
424
425
426
427
428 public double getL1Norm() {
429 double norm = 0;
430 Iterator<Entry> it = iterator();
431 while (it.hasNext()) {
432 final Entry e = it.next();
433 norm += FastMath.abs(e.getValue());
434 }
435 return norm;
436 }
437
438
439
440
441
442
443
444
445
446
447
448 public double getLInfNorm() {
449 double norm = 0;
450 Iterator<Entry> it = iterator();
451 while (it.hasNext()) {
452 final Entry e = it.next();
453 norm = FastMath.max(norm, FastMath.abs(e.getValue()));
454 }
455 return norm;
456 }
457
458
459
460
461
462
463
464
465
466
467
468
469 public double getL1Distance(RealVector v)
470 throws MathIllegalArgumentException {
471 checkVectorDimensions(v);
472 double d = 0;
473 Iterator<Entry> it = iterator();
474 while (it.hasNext()) {
475 final Entry e = it.next();
476 d += FastMath.abs(e.getValue() - v.getEntry(e.getIndex()));
477 }
478 return d;
479 }
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495 public double getLInfDistance(RealVector v)
496 throws MathIllegalArgumentException {
497 checkVectorDimensions(v);
498 double d = 0;
499 Iterator<Entry> it = iterator();
500 while (it.hasNext()) {
501 final Entry e = it.next();
502 d = FastMath.max(FastMath.abs(e.getValue() - v.getEntry(e.getIndex())), d);
503 }
504 return d;
505 }
506
507
508
509
510
511
512
513 public int getMinIndex() {
514 int minIndex = -1;
515 double minValue = Double.POSITIVE_INFINITY;
516 Iterator<Entry> iterator = iterator();
517 while (iterator.hasNext()) {
518 final Entry entry = iterator.next();
519 if (entry.getValue() <= minValue) {
520 minIndex = entry.getIndex();
521 minValue = entry.getValue();
522 }
523 }
524 return minIndex;
525 }
526
527
528
529
530
531
532
533 public double getMinValue() {
534 final int minIndex = getMinIndex();
535 return minIndex < 0 ? Double.NaN : getEntry(minIndex);
536 }
537
538
539
540
541
542
543
544 public int getMaxIndex() {
545 int maxIndex = -1;
546 double maxValue = Double.NEGATIVE_INFINITY;
547 Iterator<Entry> iterator = iterator();
548 while (iterator.hasNext()) {
549 final Entry entry = iterator.next();
550 if (entry.getValue() >= maxValue) {
551 maxIndex = entry.getIndex();
552 maxValue = entry.getValue();
553 }
554 }
555 return maxIndex;
556 }
557
558
559
560
561
562
563
564 public double getMaxValue() {
565 final int maxIndex = getMaxIndex();
566 return maxIndex < 0 ? Double.NaN : getEntry(maxIndex);
567 }
568
569
570
571
572
573
574
575
576
577 public RealVector mapMultiply(double d) {
578 return copy().mapMultiplyToSelf(d);
579 }
580
581
582
583
584
585
586
587
588 public RealVector mapMultiplyToSelf(double d){
589 return mapToSelf(FunctionUtils.fix2ndArgument(new Multiply(), d));
590 }
591
592
593
594
595
596
597
598
599 public RealVector mapSubtract(double d) {
600 return copy().mapSubtractToSelf(d);
601 }
602
603
604
605
606
607
608
609
610 public RealVector mapSubtractToSelf(double d){
611 return mapAddToSelf(-d);
612 }
613
614
615
616
617
618
619
620
621 public RealVector mapDivide(double d) {
622 return copy().mapDivideToSelf(d);
623 }
624
625
626
627
628
629
630
631
632 public RealVector mapDivideToSelf(double d){
633 return mapToSelf(FunctionUtils.fix2ndArgument(new Divide(), d));
634 }
635
636
637
638
639
640
641
642 public RealMatrix outerProduct(RealVector v) {
643 final int m = this.getDimension();
644 final int n = v.getDimension();
645 final RealMatrix product;
646 if (v instanceof SparseRealVector || this instanceof SparseRealVector) {
647 product = new OpenMapRealMatrix(m, n);
648 } else {
649 product = new Array2DRowRealMatrix(m, n);
650 }
651 for (int i = 0; i < m; i++) {
652 for (int j = 0; j < n; j++) {
653 product.setEntry(i, j, this.getEntry(i) * v.getEntry(j));
654 }
655 }
656 return product;
657 }
658
659
660
661
662
663
664
665
666
667
668
669 public RealVector projection(final RealVector v)
670 throws MathIllegalArgumentException, MathRuntimeException {
671 final double norm2 = v.dotProduct(v);
672 if (norm2 == 0.0) {
673 throw new MathRuntimeException(LocalizedCoreFormats.ZERO_NORM);
674 }
675 return v.mapMultiply(dotProduct(v) / norm2);
676 }
677
678
679
680
681
682
683 public void set(double value) {
684 Iterator<Entry> it = iterator();
685 while (it.hasNext()) {
686 final Entry e = it.next();
687 e.setValue(value);
688 }
689 }
690
691
692
693
694
695
696
697
698 public double[] toArray() {
699 int dim = getDimension();
700 double[] values = new double[dim];
701 for (int i = 0; i < dim; i++) {
702 values[i] = getEntry(i);
703 }
704 return values;
705 }
706
707
708
709
710
711
712
713
714 public RealVector unitVector() throws MathRuntimeException {
715 final double norm = getNorm();
716 if (norm == 0) {
717 throw new MathRuntimeException(LocalizedCoreFormats.ZERO_NORM);
718 }
719 return mapDivide(norm);
720 }
721
722
723
724
725
726
727
728 public void unitize() throws MathRuntimeException {
729 final double norm = getNorm();
730 if (norm == 0) {
731 throw new MathRuntimeException(LocalizedCoreFormats.ZERO_NORM);
732 }
733 mapDivideToSelf(getNorm());
734 }
735
736
737
738
739
740
741
742
743
744
745
746
747
748 public Iterator<Entry> sparseIterator() {
749 return new SparseEntryIterator();
750 }
751
752
753
754
755
756
757
758
759
760
761
762 public Iterator<Entry> iterator() {
763 final int dim = getDimension();
764 return new Iterator<Entry>() {
765
766
767 private int i;
768
769
770 private Entry e = new Entry();
771
772
773 @Override
774 public boolean hasNext() {
775 return i < dim;
776 }
777
778
779 @Override
780 public Entry next() {
781 if (i < dim) {
782 e.setIndex(i++);
783 return e;
784 } else {
785 throw new NoSuchElementException();
786 }
787 }
788
789
790
791
792
793
794 @Override
795 public void remove() throws MathRuntimeException {
796 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
797 }
798 };
799 }
800
801
802
803
804
805
806
807
808
809
810
811 public RealVector map(UnivariateFunction function) {
812 return copy().mapToSelf(function);
813 }
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828 public RealVector mapToSelf(UnivariateFunction function) {
829 Iterator<Entry> it = iterator();
830 while (it.hasNext()) {
831 final Entry e = it.next();
832 e.setValue(function.value(e.getValue()));
833 }
834 return this;
835 }
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850 public RealVector combine(double a, double b, RealVector y)
851 throws MathIllegalArgumentException {
852 return copy().combineToSelf(a, b, y);
853 }
854
855
856
857
858
859
860
861
862
863
864
865
866
867 public RealVector combineToSelf(double a, double b, RealVector y)
868 throws MathIllegalArgumentException {
869 checkVectorDimensions(y);
870 for (int i = 0; i < getDimension(); i++) {
871 final double xi = getEntry(i);
872 final double yi = y.getEntry(i);
873 setEntry(i, a * xi + b * yi);
874 }
875 return this;
876 }
877
878
879
880
881
882
883
884
885
886
887 public double walkInDefaultOrder(final RealVectorPreservingVisitor visitor) {
888 final int dim = getDimension();
889 visitor.start(dim, 0, dim - 1);
890 for (int i = 0; i < dim; i++) {
891 visitor.visit(i, getEntry(i));
892 }
893 return visitor.end();
894 }
895
896
897
898
899
900
901
902
903
904
905
906
907
908 public double walkInDefaultOrder(final RealVectorPreservingVisitor visitor,
909 final int start, final int end)
910 throws MathIllegalArgumentException {
911 checkIndices(start, end);
912 visitor.start(getDimension(), start, end);
913 for (int i = start; i <= end; i++) {
914 visitor.visit(i, getEntry(i));
915 }
916 return visitor.end();
917 }
918
919
920
921
922
923
924
925
926
927
928
929
930 public double walkInOptimizedOrder(final RealVectorPreservingVisitor visitor) {
931 return walkInDefaultOrder(visitor);
932 }
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948 public double walkInOptimizedOrder(final RealVectorPreservingVisitor visitor,
949 final int start, final int end)
950 throws MathIllegalArgumentException {
951 return walkInDefaultOrder(visitor, start, end);
952 }
953
954
955
956
957
958
959
960
961
962
963 public double walkInDefaultOrder(final RealVectorChangingVisitor visitor) {
964 final int dim = getDimension();
965 visitor.start(dim, 0, dim - 1);
966 for (int i = 0; i < dim; i++) {
967 setEntry(i, visitor.visit(i, getEntry(i)));
968 }
969 return visitor.end();
970 }
971
972
973
974
975
976
977
978
979
980
981
982
983
984 public double walkInDefaultOrder(final RealVectorChangingVisitor visitor,
985 final int start, final int end)
986 throws MathIllegalArgumentException {
987 checkIndices(start, end);
988 visitor.start(getDimension(), start, end);
989 for (int i = start; i <= end; i++) {
990 setEntry(i, visitor.visit(i, getEntry(i)));
991 }
992 return visitor.end();
993 }
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006 public double walkInOptimizedOrder(final RealVectorChangingVisitor visitor) {
1007 return walkInDefaultOrder(visitor);
1008 }
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024 public double walkInOptimizedOrder(final RealVectorChangingVisitor visitor,
1025 final int start, final int end)
1026 throws MathIllegalArgumentException {
1027 return walkInDefaultOrder(visitor, start, end);
1028 }
1029
1030
1031 public class Entry {
1032
1033 private int index;
1034
1035
1036 public Entry() {
1037 setIndex(0);
1038 }
1039
1040
1041
1042
1043
1044
1045 public double getValue() {
1046 return getEntry(getIndex());
1047 }
1048
1049
1050
1051
1052
1053
1054 public void setValue(double value) {
1055 setEntry(getIndex(), value);
1056 }
1057
1058
1059
1060
1061
1062
1063 public int getIndex() {
1064 return index;
1065 }
1066
1067
1068
1069
1070
1071
1072 public void setIndex(int index) {
1073 this.index = index;
1074 }
1075 }
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099 @Override
1100 public boolean equals(Object other)
1101 throws MathRuntimeException {
1102 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1103 }
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113 @Override
1114 public int hashCode() throws MathRuntimeException {
1115 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1116 }
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132 protected class SparseEntryIterator implements Iterator<Entry> {
1133
1134 private final int dim;
1135
1136 private Entry current;
1137
1138 private Entry next;
1139
1140
1141 protected SparseEntryIterator() {
1142 dim = getDimension();
1143 current = new Entry();
1144 next = new Entry();
1145 if (next.getValue() == 0) {
1146 advance(next);
1147 }
1148 }
1149
1150
1151
1152
1153
1154
1155 protected void advance(Entry e) {
1156 if (e == null) {
1157 return;
1158 }
1159 do {
1160 e.setIndex(e.getIndex() + 1);
1161 } while (e.getIndex() < dim && e.getValue() == 0);
1162 if (e.getIndex() >= dim) {
1163 e.setIndex(-1);
1164 }
1165 }
1166
1167
1168 @Override
1169 public boolean hasNext() {
1170 return next.getIndex() >= 0;
1171 }
1172
1173
1174 @Override
1175 public Entry next() {
1176 int index = next.getIndex();
1177 if (index < 0) {
1178 throw new NoSuchElementException();
1179 }
1180 current.setIndex(index);
1181 advance(next);
1182 return current;
1183 }
1184
1185
1186
1187
1188
1189
1190 @Override
1191 public void remove() throws MathRuntimeException {
1192 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1193 }
1194 }
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214 public static RealVector unmodifiableRealVector(final RealVector v) {
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224 return new RealVector() {
1225
1226
1227
1228
1229
1230 @Override
1231 public RealVector mapToSelf(UnivariateFunction function)
1232 throws MathRuntimeException {
1233 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1234 }
1235
1236
1237 @Override
1238 public RealVector map(UnivariateFunction function) {
1239 return v.map(function);
1240 }
1241
1242
1243 @Override
1244 public Iterator<Entry> iterator() {
1245 final Iterator<Entry> i = v.iterator();
1246 return new Iterator<Entry>() {
1247
1248 private final UnmodifiableEntry e = new UnmodifiableEntry();
1249
1250
1251 @Override
1252 public boolean hasNext() {
1253 return i.hasNext();
1254 }
1255
1256
1257 @Override
1258 public Entry next() {
1259 e.setIndex(i.next().getIndex());
1260 return e;
1261 }
1262
1263
1264
1265
1266
1267
1268
1269 @Override
1270 public void remove() throws MathRuntimeException {
1271 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1272 }
1273 };
1274 }
1275
1276
1277 @Override
1278 public Iterator<Entry> sparseIterator() {
1279 final Iterator<Entry> i = v.sparseIterator();
1280
1281 return new Iterator<Entry>() {
1282
1283 private final UnmodifiableEntry e = new UnmodifiableEntry();
1284
1285
1286 @Override
1287 public boolean hasNext() {
1288 return i.hasNext();
1289 }
1290
1291
1292 @Override
1293 public Entry next() {
1294 e.setIndex(i.next().getIndex());
1295 return e;
1296 }
1297
1298
1299
1300
1301
1302
1303
1304 @Override
1305 public void remove()
1306 throws MathRuntimeException {
1307 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1308 }
1309 };
1310 }
1311
1312
1313 @Override
1314 public RealVector copy() {
1315 return v.copy();
1316 }
1317
1318
1319 @Override
1320 public RealVector add(RealVector w)
1321 throws MathIllegalArgumentException {
1322 return v.add(w);
1323 }
1324
1325
1326 @Override
1327 public RealVector subtract(RealVector w)
1328 throws MathIllegalArgumentException {
1329 return v.subtract(w);
1330 }
1331
1332
1333 @Override
1334 public RealVector mapAdd(double d) {
1335 return v.mapAdd(d);
1336 }
1337
1338
1339
1340
1341
1342
1343
1344 @Override
1345 public RealVector mapAddToSelf(double d)
1346 throws MathRuntimeException {
1347 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1348 }
1349
1350
1351 @Override
1352 public RealVector mapSubtract(double d) {
1353 return v.mapSubtract(d);
1354 }
1355
1356
1357
1358
1359
1360
1361
1362 @Override
1363 public RealVector mapSubtractToSelf(double d)
1364 throws MathRuntimeException {
1365 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1366 }
1367
1368
1369 @Override
1370 public RealVector mapMultiply(double d) {
1371 return v.mapMultiply(d);
1372 }
1373
1374
1375
1376
1377
1378
1379
1380 @Override
1381 public RealVector mapMultiplyToSelf(double d)
1382 throws MathRuntimeException {
1383 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1384 }
1385
1386
1387 @Override
1388 public RealVector mapDivide(double d) {
1389 return v.mapDivide(d);
1390 }
1391
1392
1393
1394
1395
1396
1397
1398 @Override
1399 public RealVector mapDivideToSelf(double d)
1400 throws MathRuntimeException {
1401 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1402 }
1403
1404
1405 @Override
1406 public RealVector ebeMultiply(RealVector w)
1407 throws MathIllegalArgumentException {
1408 return v.ebeMultiply(w);
1409 }
1410
1411
1412 @Override
1413 public RealVector ebeDivide(RealVector w)
1414 throws MathIllegalArgumentException {
1415 return v.ebeDivide(w);
1416 }
1417
1418
1419 @Override
1420 public double dotProduct(RealVector w)
1421 throws MathIllegalArgumentException {
1422 return v.dotProduct(w);
1423 }
1424
1425
1426 @Override
1427 public double cosine(RealVector w)
1428 throws MathIllegalArgumentException, MathRuntimeException {
1429 return v.cosine(w);
1430 }
1431
1432
1433 @Override
1434 public double getNorm() {
1435 return v.getNorm();
1436 }
1437
1438
1439 @Override
1440 public double getL1Norm() {
1441 return v.getL1Norm();
1442 }
1443
1444
1445 @Override
1446 public double getLInfNorm() {
1447 return v.getLInfNorm();
1448 }
1449
1450
1451 @Override
1452 public double getDistance(RealVector w)
1453 throws MathIllegalArgumentException {
1454 return v.getDistance(w);
1455 }
1456
1457
1458 @Override
1459 public double getL1Distance(RealVector w)
1460 throws MathIllegalArgumentException {
1461 return v.getL1Distance(w);
1462 }
1463
1464
1465 @Override
1466 public double getLInfDistance(RealVector w)
1467 throws MathIllegalArgumentException {
1468 return v.getLInfDistance(w);
1469 }
1470
1471
1472 @Override
1473 public RealVector unitVector() throws MathRuntimeException {
1474 return v.unitVector();
1475 }
1476
1477
1478
1479
1480
1481
1482
1483 @Override
1484 public void unitize() throws MathRuntimeException {
1485 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1486 }
1487
1488
1489 @Override
1490 public RealMatrix outerProduct(RealVector w) {
1491 return v.outerProduct(w);
1492 }
1493
1494
1495 @Override
1496 public double getEntry(int index) throws MathIllegalArgumentException {
1497 return v.getEntry(index);
1498 }
1499
1500
1501
1502
1503
1504
1505
1506 @Override
1507 public void setEntry(int index, double value)
1508 throws MathRuntimeException {
1509 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1510 }
1511
1512
1513
1514
1515
1516
1517
1518 @Override
1519 public void addToEntry(int index, double value)
1520 throws MathRuntimeException {
1521 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1522 }
1523
1524
1525 @Override
1526 public int getDimension() {
1527 return v.getDimension();
1528 }
1529
1530
1531 @Override
1532 public RealVector append(RealVector w) {
1533 return v.append(w);
1534 }
1535
1536
1537 @Override
1538 public RealVector append(double d) {
1539 return v.append(d);
1540 }
1541
1542
1543 @Override
1544 public RealVector getSubVector(int index, int n)
1545 throws MathIllegalArgumentException {
1546 return v.getSubVector(index, n);
1547 }
1548
1549
1550
1551
1552
1553
1554
1555 @Override
1556 public void setSubVector(int index, RealVector w)
1557 throws MathRuntimeException {
1558 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1559 }
1560
1561
1562
1563
1564
1565
1566
1567 @Override
1568 public void set(double value)
1569 throws MathRuntimeException {
1570 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1571 }
1572
1573
1574 @Override
1575 public double[] toArray() {
1576 return v.toArray();
1577 }
1578
1579
1580 @Override
1581 public boolean isNaN() {
1582 return v.isNaN();
1583 }
1584
1585
1586 @Override
1587 public boolean isInfinite() {
1588 return v.isInfinite();
1589 }
1590
1591
1592 @Override
1593 public RealVector combine(double a, double b, RealVector y)
1594 throws MathIllegalArgumentException {
1595 return v.combine(a, b, y);
1596 }
1597
1598
1599
1600
1601
1602
1603
1604 @Override
1605 public RealVector combineToSelf(double a, double b, RealVector y)
1606 throws MathRuntimeException {
1607 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1608 }
1609
1610
1611 class UnmodifiableEntry extends Entry {
1612
1613 @Override
1614 public double getValue() {
1615 return v.getEntry(getIndex());
1616 }
1617
1618
1619
1620
1621
1622
1623
1624 @Override
1625 public void setValue(double value)
1626 throws MathRuntimeException {
1627 throw new MathRuntimeException(LocalizedCoreFormats.UNSUPPORTED_OPERATION);
1628 }
1629 }
1630 };
1631 }
1632 }