001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.math.linear;
018    
019    /**
020     * Interface defining a real-valued vector with basic algebraic operations.
021     * <p>
022     * vector element indexing is 0-based -- e.g., <code>getEntry(0)</code>
023     * returns the first element of the vector.
024     * </p>
025     * <p>
026     * The various <code>mapXxx</code> and <code>mapXxxToSelf</code> methods operate
027     * on vectors element-wise, i.e. they perform the same operation (adding a scalar,
028     * applying a function ...) on each element in turn. The <code>mapXxx</code>
029     * versions create a new vector to hold the result and do not change the instance.
030     * The <code>mapXxxToSelf</code> versions use the instance itself to store the
031     * results, so the instance is changed by these methods. In both cases, the result
032     * vector is returned by the methods, this allows to use the <i>fluent API</i>
033     * style, like this:
034     * </p>
035     * <pre>
036     *   RealVector result = v.mapAddToSelf(3.0).mapTanToSelf().mapSquareToSelf();
037     * </pre>
038     *
039     * @version $Revision: 811786 $ $Date: 2009-09-06 05:36:08 -0400 (Sun, 06 Sep 2009) $
040     * @since 2.0
041     */
042    public interface RealVector {
043    
044        /**
045         * Returns a (deep) copy of this.
046         * @return vector copy
047         */
048        RealVector copy();
049    
050        /**
051         * Compute the sum of this and v.
052         * @param v vector to be added
053         * @return this + v
054         * @throws IllegalArgumentException if v is not the same size as this
055         */
056        RealVector add(RealVector v)
057            throws IllegalArgumentException;
058    
059        /**
060         * Compute the sum of this and v.
061         * @param v vector to be added
062         * @return this + v
063         * @throws IllegalArgumentException if v is not the same size as this
064         */
065        RealVector add(double[] v)
066            throws IllegalArgumentException;
067    
068        /**
069         * Compute this minus v.
070         * @param v vector to be subtracted
071         * @return this + v
072         * @throws IllegalArgumentException if v is not the same size as this
073         */
074        RealVector subtract(RealVector v)
075            throws IllegalArgumentException;
076    
077        /**
078         * Compute this minus v.
079         * @param v vector to be subtracted
080         * @return this + v
081         * @throws IllegalArgumentException if v is not the same size as this
082         */
083        RealVector subtract(double[] v)
084            throws IllegalArgumentException;
085    
086        /**
087         * Map an addition operation to each entry.
088         * @param d value to be added to each entry
089         * @return this + d
090         */
091        RealVector mapAdd(double d);
092    
093        /**
094         * Map an addition operation to each entry.
095         * <p>The instance <strong>is</strong> changed by this method.</p>
096         * @param d value to be added to each entry
097         * @return for convenience, return this
098         */
099        RealVector mapAddToSelf(double d);
100    
101        /**
102         * Map a subtraction operation to each entry.
103         * @param d value to be subtracted to each entry
104         * @return this - d
105         */
106        RealVector mapSubtract(double d);
107    
108        /**
109         * Map a subtraction operation to each entry.
110         * <p>The instance <strong>is</strong> changed by this method.</p>
111         * @param d value to be subtracted to each entry
112         * @return for convenience, return this
113         */
114        RealVector mapSubtractToSelf(double d);
115    
116        /**
117         * Map a multiplication operation to each entry.
118         * @param d value to multiply all entries by
119         * @return this * d
120         */
121        RealVector mapMultiply(double d);
122    
123        /**
124         * Map a multiplication operation to each entry.
125         * <p>The instance <strong>is</strong> changed by this method.</p>
126         * @param d value to multiply all entries by
127         * @return for convenience, return this
128         */
129        RealVector mapMultiplyToSelf(double d);
130    
131        /**
132         * Map a division operation to each entry.
133         * @param d value to divide all entries by
134         * @return this / d
135         */
136        RealVector mapDivide(double d);
137    
138        /**
139         * Map a division operation to each entry.
140         * <p>The instance <strong>is</strong> changed by this method.</p>
141         * @param d value to divide all entries by
142         * @return for convenience, return this
143         */
144        RealVector mapDivideToSelf(double d);
145    
146        /**
147         * Map a power operation to each entry.
148         * @param d value to raise all entries to
149         * @return this ^ d
150         */
151        RealVector mapPow(double d);
152    
153        /**
154         * Map a power operation to each entry.
155         * <p>The instance <strong>is</strong> changed by this method.</p>
156         * @param d value to raise all entries to
157         * @return for convenience, return this
158         */
159        RealVector mapPowToSelf(double d);
160    
161        /**
162         * Map the {@link Math#exp(double)} function to each entry.
163         * @return a vector containing the result of applying the function to each entry
164         */
165        RealVector mapExp();
166    
167        /**
168         * Map the {@link Math#exp(double)} function to each entry.
169         * <p>The instance <strong>is</strong> changed by this method.</p>
170         * @return for convenience, return this
171         */
172        RealVector mapExpToSelf();
173    
174        /**
175         * Map the {@link Math#expm1(double)} function to each entry.
176         * @return a vector containing the result of applying the function to each entry
177         */
178        RealVector mapExpm1();
179    
180        /**
181         * Map the {@link Math#expm1(double)} function to each entry.
182         * <p>The instance <strong>is</strong> changed by this method.</p>
183         * @return for convenience, return this
184         */
185        RealVector mapExpm1ToSelf();
186    
187        /**
188         * Map the {@link Math#log(double)} function to each entry.
189         * @return a vector containing the result of applying the function to each entry
190         */
191        RealVector mapLog();
192    
193        /**
194         * Map the {@link Math#log(double)} function to each entry.
195         * <p>The instance <strong>is</strong> changed by this method.</p>
196         * @return for convenience, return this
197         */
198        RealVector mapLogToSelf();
199    
200        /**
201         * Map the {@link Math#log10(double)} function to each entry.
202         * @return a vector containing the result of applying the function to each entry
203         */
204        RealVector mapLog10();
205    
206        /**
207         * Map the {@link Math#log10(double)} function to each entry.
208         * <p>The instance <strong>is</strong> changed by this method.</p>
209         * @return for convenience, return this
210         */
211        RealVector mapLog10ToSelf();
212    
213        /**
214         * Map the {@link Math#log1p(double)} function to each entry.
215         * @return a vector containing the result of applying the function to each entry
216         */
217        RealVector mapLog1p();
218    
219        /**
220         * Map the {@link Math#log1p(double)} function to each entry.
221         * <p>The instance <strong>is</strong> changed by this method.</p>
222         * @return for convenience, return this
223         */
224        RealVector mapLog1pToSelf();
225    
226        /**
227         * Map the {@link Math#cosh(double)} function to each entry.
228         * @return a vector containing the result of applying the function to each entry
229         */
230        RealVector mapCosh();
231    
232        /**
233         * Map the {@link Math#cosh(double)} function to each entry.
234         * <p>The instance <strong>is</strong> changed by this method.</p>
235         * @return for convenience, return this
236         */
237        RealVector mapCoshToSelf();
238    
239        /**
240         * Map the {@link Math#sinh(double)} function to each entry.
241         * @return a vector containing the result of applying the function to each entry
242         */
243        RealVector mapSinh();
244    
245        /**
246         * Map the {@link Math#sinh(double)} function to each entry.
247         * <p>The instance <strong>is</strong> changed by this method.</p>
248         * @return for convenience, return this
249         */
250        RealVector mapSinhToSelf();
251    
252        /**
253         * Map the {@link Math#tanh(double)} function to each entry.
254         * @return a vector containing the result of applying the function to each entry
255         */
256        RealVector mapTanh();
257    
258        /**
259         * Map the {@link Math#tanh(double)} function to each entry.
260         * <p>The instance <strong>is</strong> changed by this method.</p>
261         * @return for convenience, return this
262         */
263        RealVector mapTanhToSelf();
264    
265        /**
266         * Map the {@link Math#cos(double)} function to each entry.
267         * @return a vector containing the result of applying the function to each entry
268         */
269        RealVector mapCos();
270    
271        /**
272         * Map the {@link Math#cos(double)} function to each entry.
273         * <p>The instance <strong>is</strong> changed by this method.</p>
274         * @return for convenience, return this
275         */
276        RealVector mapCosToSelf();
277    
278        /**
279         * Map the {@link Math#sin(double)} function to each entry.
280         * @return a vector containing the result of applying the function to each entry
281         */
282        RealVector mapSin();
283    
284        /**
285         * Map the {@link Math#sin(double)} function to each entry.
286         * <p>The instance <strong>is</strong> changed by this method.</p>
287         * @return for convenience, return this
288         */
289        RealVector mapSinToSelf();
290    
291        /**
292         * Map the {@link Math#tan(double)} function to each entry.
293         * @return a vector containing the result of applying the function to each entry
294         */
295        RealVector mapTan();
296    
297        /**
298         * Map the {@link Math#tan(double)} function to each entry.
299         * <p>The instance <strong>is</strong> changed by this method.</p>
300         * @return for convenience, return this
301         */
302        RealVector mapTanToSelf();
303    
304        /**
305         * Map the {@link Math#acos(double)} function to each entry.
306         * @return a vector containing the result of applying the function to each entry
307         */
308        RealVector mapAcos();
309    
310        /**
311         * Map the {@link Math#acos(double)} function to each entry.
312         * <p>The instance <strong>is</strong> changed by this method.</p>
313         * @return for convenience, return this
314         */
315        RealVector mapAcosToSelf();
316    
317        /**
318         * Map the {@link Math#asin(double)} function to each entry.
319         * @return a vector containing the result of applying the function to each entry
320         */
321        RealVector mapAsin();
322    
323        /**
324         * Map the {@link Math#asin(double)} function to each entry.
325         * <p>The instance <strong>is</strong> changed by this method.</p>
326         * @return for convenience, return this
327         */
328        RealVector mapAsinToSelf();
329    
330        /**
331         * Map the {@link Math#atan(double)} function to each entry.
332         * @return a vector containing the result of applying the function to each entry
333         */
334        RealVector mapAtan();
335    
336        /**
337         * Map the {@link Math#atan(double)} function to each entry.
338         * <p>The instance <strong>is</strong> changed by this method.</p>
339         * @return for convenience, return this
340         */
341        RealVector mapAtanToSelf();
342    
343        /**
344         * Map the 1/x function to each entry.
345         * @return a vector containing the result of applying the function to each entry
346         */
347        RealVector mapInv();
348    
349        /**
350         * Map the 1/x function to each entry.
351         * <p>The instance <strong>is</strong> changed by this method.</p>
352         * @return for convenience, return this
353         */
354        RealVector mapInvToSelf();
355    
356        /**
357         * Map the {@link Math#abs(double)} function to each entry.
358         * @return a vector containing the result of applying the function to each entry
359         */
360        RealVector mapAbs();
361    
362        /**
363         * Map the {@link Math#abs(double)} function to each entry.
364         * <p>The instance <strong>is</strong> changed by this method.</p>
365         * @return for convenience, return this
366         */
367        RealVector mapAbsToSelf();
368    
369        /**
370         * Map the {@link Math#sqrt(double)} function to each entry.
371         * @return a vector containing the result of applying the function to each entry
372         */
373        RealVector mapSqrt();
374    
375        /**
376         * Map the {@link Math#sqrt(double)} function to each entry.
377         * <p>The instance <strong>is</strong> changed by this method.</p>
378         * @return for convenience, return this
379         */
380        RealVector mapSqrtToSelf();
381    
382        /**
383         * Map the {@link Math#cbrt(double)} function to each entry.
384         * @return a vector containing the result of applying the function to each entry
385         */
386        RealVector mapCbrt();
387    
388        /**
389         * Map the {@link Math#cbrt(double)} function to each entry.
390         * <p>The instance <strong>is</strong> changed by this method.</p>
391         * @return for convenience, return this
392         */
393        RealVector mapCbrtToSelf();
394    
395        /**
396         * Map the {@link Math#ceil(double)} function to each entry.
397         * @return a vector containing the result of applying the function to each entry
398         */
399        RealVector mapCeil();
400    
401        /**
402         * Map the {@link Math#ceil(double)} function to each entry.
403         * <p>The instance <strong>is</strong> changed by this method.</p>
404         * @return for convenience, return this
405         */
406        RealVector mapCeilToSelf();
407    
408        /**
409         * Map the {@link Math#floor(double)} function to each entry.
410         * @return a vector containing the result of applying the function to each entry
411         */
412        RealVector mapFloor();
413    
414        /**
415         * Map the {@link Math#floor(double)} function to each entry.
416         * <p>The instance <strong>is</strong> changed by this method.</p>
417         * @return for convenience, return this
418         */
419        RealVector mapFloorToSelf();
420    
421        /**
422         * Map the {@link Math#rint(double)} function to each entry.
423         * @return a vector containing the result of applying the function to each entry
424         */
425        RealVector mapRint();
426    
427        /**
428         * Map the {@link Math#rint(double)} function to each entry.
429         * <p>The instance <strong>is</strong> changed by this method.</p>
430         * @return for convenience, return this
431         */
432        RealVector mapRintToSelf();
433    
434        /**
435         * Map the {@link Math#signum(double)} function to each entry.
436         * @return a vector containing the result of applying the function to each entry
437         */
438        RealVector mapSignum();
439    
440        /**
441         * Map the {@link Math#signum(double)} function to each entry.
442         * <p>The instance <strong>is</strong> changed by this method.</p>
443         * @return for convenience, return this
444         */
445        RealVector mapSignumToSelf();
446    
447        /**
448         * Map the {@link Math#ulp(double)} function to each entry.
449         * @return a vector containing the result of applying the function to each entry
450         */
451        RealVector mapUlp();
452    
453        /**
454         * Map the {@link Math#ulp(double)} function to each entry.
455         * <p>The instance <strong>is</strong> changed by this method.</p>
456         * @return for convenience, return this
457         */
458        RealVector mapUlpToSelf();
459    
460        /**
461         * Element-by-element multiplication.
462         * @param v vector by which instance elements must be multiplied
463         * @return a vector containing this[i] * v[i] for all i
464         * @throws IllegalArgumentException if v is not the same size as this
465         */
466        RealVector ebeMultiply(RealVector v) throws IllegalArgumentException;
467    
468        /**
469         * Element-by-element multiplication.
470         * @param v vector by which instance elements must be multiplied
471         * @return a vector containing this[i] * v[i] for all i
472         * @throws IllegalArgumentException if v is not the same size as this
473         */
474        RealVector ebeMultiply(double[] v) throws IllegalArgumentException;
475    
476        /**
477         * Element-by-element division.
478         * @param v vector by which instance elements must be divided
479         * @return a vector containing this[i] / v[i] for all i
480         * @throws IllegalArgumentException if v is not the same size as this
481         */
482        RealVector ebeDivide(RealVector v) throws IllegalArgumentException;
483    
484        /**
485         * Element-by-element division.
486         * @param v vector by which instance elements must be divided
487         * @return a vector containing this[i] / v[i] for all i
488         * @throws IllegalArgumentException if v is not the same size as this
489         */
490        RealVector ebeDivide(double[] v) throws IllegalArgumentException;
491    
492        /**
493         * Returns vector entries as a double array.
494         * @return double array of entries
495         */
496         double[] getData();
497    
498        /**
499         * Compute the dot product.
500         * @param v vector with which dot product should be computed
501         * @return the scalar dot product between instance and v
502         * @exception IllegalArgumentException if v is not the same size as this
503         */
504        double dotProduct(RealVector v)
505            throws IllegalArgumentException;
506    
507        /**
508         * Compute the dot product.
509         * @param v vector with which dot product should be computed
510         * @return the scalar dot product between instance and v
511         * @exception IllegalArgumentException if v is not the same size as this
512         */
513        double dotProduct(double[] v)
514            throws IllegalArgumentException;
515    
516        /**
517         * Returns the L<sub>2</sub> norm of the vector.
518         * <p>The L<sub>2</sub> norm is the root of the sum of
519         * the squared elements.</p>
520         * @return norm
521         * @see #getL1Norm()
522         * @see #getLInfNorm()
523         * @see #getDistance(RealVector)
524         */
525        double getNorm();
526    
527        /**
528         * Returns the L<sub>1</sub> norm of the vector.
529         * <p>The L<sub>1</sub> norm is the sum of the absolute
530         * values of elements.</p>
531         * @return norm
532         * @see #getNorm()
533         * @see #getLInfNorm()
534         * @see #getL1Distance(RealVector)
535         */
536        double getL1Norm();
537    
538        /**
539         * Returns the L<sub>&infin;</sub> norm of the vector.
540         * <p>The L<sub>&infin;</sub> norm is the max of the absolute
541         * values of elements.</p>
542         * @return norm
543         * @see #getNorm()
544         * @see #getL1Norm()
545         * @see #getLInfDistance(RealVector)
546         */
547        double getLInfNorm();
548    
549        /**
550         * Distance between two vectors.
551         * <p>This method computes the distance consistent with the
552         * L<sub>2</sub> norm, i.e. the square root of the sum of
553         * elements differences, or euclidian distance.</p>
554         * @param v vector to which distance is requested
555         * @return distance between two vectors.
556         * @exception IllegalArgumentException if v is not the same size as this
557         * @see #getL1Distance(RealVector)
558         * @see #getLInfDistance(RealVector)
559         * @see #getNorm()
560         */
561        double getDistance(RealVector v)
562            throws IllegalArgumentException;
563    
564        /**
565         * Distance between two vectors.
566         * <p>This method computes the distance consistent with the
567         * L<sub>2</sub> norm, i.e. the square root of the sum of
568         * elements differences, or euclidian distance.</p>
569         * @param v vector to which distance is requested
570         * @return distance between two vectors.
571         * @exception IllegalArgumentException if v is not the same size as this
572         * @see #getL1Distance(double[])
573         * @see #getLInfDistance(double[])
574         * @see #getNorm()
575         */
576        double getDistance(double[] v)
577            throws IllegalArgumentException;
578    
579        /**
580         * Distance between two vectors.
581         * <p>This method computes the distance consistent with
582         * L<sub>1</sub> norm, i.e. the sum of the absolute values of
583         * elements differences.</p>
584         * @param v vector to which distance is requested
585         * @return distance between two vectors.
586         * @exception IllegalArgumentException if v is not the same size as this
587         * @see #getDistance(RealVector)
588         * @see #getLInfDistance(RealVector)
589         * @see #getL1Norm()
590         */
591        double getL1Distance(RealVector v)
592            throws IllegalArgumentException;
593    
594        /**
595         * Distance between two vectors.
596         * <p>This method computes the distance consistent with
597         * L<sub>1</sub> norm, i.e. the sum of the absolute values of
598         * elements differences.</p>
599         * @param v vector to which distance is requested
600         * @return distance between two vectors.
601         * @exception IllegalArgumentException if v is not the same size as this
602         * @see #getDistance(double[])
603         * @see #getLInfDistance(double[])
604         * @see #getL1Norm()
605         */
606        double getL1Distance(double[] v)
607            throws IllegalArgumentException;
608    
609        /**
610         * Distance between two vectors.
611         * <p>This method computes the distance consistent with
612         * L<sub>&infin;</sub> norm, i.e. the max of the absolute values of
613         * elements differences.</p>
614         * @param v vector to which distance is requested
615         * @return distance between two vectors.
616         * @exception IllegalArgumentException if v is not the same size as this
617         * @see #getDistance(RealVector)
618         * @see #getL1Distance(RealVector)
619         * @see #getLInfNorm()
620         */
621        double getLInfDistance(RealVector v)
622            throws IllegalArgumentException;
623    
624        /**
625         * Distance between two vectors.
626         * <p>This method computes the distance consistent with
627         * L<sub>&infin;</sub> norm, i.e. the max of the absolute values of
628         * elements differences.</p>
629         * @param v vector to which distance is requested
630         * @return distance between two vectors.
631         * @exception IllegalArgumentException if v is not the same size as this
632         * @see #getDistance(double[])
633         * @see #getL1Distance(double[])
634         * @see #getLInfNorm()
635         */
636        double getLInfDistance(double[] v)
637            throws IllegalArgumentException;
638    
639        /** Creates a unit vector pointing in the direction of this vector.
640         * <p>The instance is not changed by this method.</p>
641         * @return a unit vector pointing in direction of this vector
642         * @exception ArithmeticException if the norm is null
643         */
644        RealVector unitVector();
645    
646        /** Converts this vector into a unit vector.
647         * <p>The instance itself is changed by this method.</p>
648         * @exception ArithmeticException if the norm is null
649         */
650        void unitize();
651    
652        /** Find the orthogonal projection of this vector onto another vector.
653         * @param v vector onto which instance must be projected
654         * @return projection of the instance onto v
655         * @throws IllegalArgumentException if v is not the same size as this
656         */
657        RealVector projection(RealVector v)
658            throws IllegalArgumentException;
659    
660        /** Find the orthogonal projection of this vector onto another vector.
661         * @param v vector onto which instance must be projected
662         * @return projection of the instance onto v
663         * @throws IllegalArgumentException if v is not the same size as this
664         */
665        RealVector projection(double[] v)
666            throws IllegalArgumentException;
667    
668        /**
669         * Compute the outer product.
670         * @param v vector with which outer product should be computed
671         * @return the square matrix outer product between instance and v
672         * @exception IllegalArgumentException if v is not the same size as this
673         */
674        RealMatrix outerProduct(RealVector v)
675            throws IllegalArgumentException;
676    
677        /**
678         * Compute the outer product.
679         * @param v vector with which outer product should be computed
680         * @return the square matrix outer product between instance and v
681         * @exception IllegalArgumentException if v is not the same size as this
682         */
683        RealMatrix outerProduct(double[] v)
684            throws IllegalArgumentException;
685    
686        /**
687         * Returns the entry in the specified index.
688         * <p>
689         * The index start at 0 and must be lesser than the size,
690         * otherwise a {@link MatrixIndexException} is thrown.
691         * </p>
692         * @param index  index location of entry to be fetched
693         * @return vector entry at index
694         * @throws MatrixIndexException if the index is not valid
695         * @see #setEntry(int, double)
696         */
697        double getEntry(int index)
698            throws MatrixIndexException;
699    
700        /**
701         * Set a single element.
702         * @param index element index.
703         * @param value new value for the element.
704         * @exception MatrixIndexException if the index is
705         * inconsistent with vector size
706         * @see #getEntry(int)
707         */
708        void setEntry(int index, double value)
709            throws MatrixIndexException;
710    
711        /**
712         * Returns the size of the vector.
713         * @return size
714         */
715        int getDimension();
716    
717        /**
718         * Construct a vector by appending a vector to this vector.
719         * @param v vector to append to this one.
720         * @return a new vector
721         */
722        RealVector append(RealVector v);
723    
724        /**
725         * Construct a vector by appending a double to this vector.
726         * @param d double to append.
727         * @return a new vector
728         */
729        RealVector append(double d);
730    
731        /**
732         * Construct a vector by appending a double array to this vector.
733         * @param a double array to append.
734         * @return a new vector
735         */
736        RealVector append(double[] a);
737    
738        /**
739         * Get a subvector from consecutive elements.
740         * @param index index of first element.
741         * @param n number of elements to be retrieved.
742         * @return a vector containing n elements.
743         * @exception MatrixIndexException if the index is
744         * inconsistent with vector size
745         */
746        RealVector getSubVector(int index, int n)
747            throws MatrixIndexException;
748    
749        /**
750         * Set a set of consecutive elements.
751         * @param index index of first element to be set.
752         * @param v vector containing the values to set.
753         * @exception MatrixIndexException if the index is
754         * inconsistent with vector size
755         * @see #setSubVector(int, double[])
756         */
757        void setSubVector(int index, RealVector v)
758            throws MatrixIndexException;
759    
760        /**
761         * Set a set of consecutive elements.
762         * @param index index of first element to be set.
763         * @param v vector containing the values to set.
764         * @exception MatrixIndexException if the index is
765         * inconsistent with vector size
766         * @see #setSubVector(int, RealVector)
767         */
768        void setSubVector(int index, double[] v)
769            throws MatrixIndexException;
770    
771        /**
772         * Set all elements to a single value.
773         * @param value single value to set for all elements
774         */
775        void set(double value);
776    
777        /**
778         * Convert the vector to a double array.
779         * <p>The array is independent from vector data, it's elements
780         * are copied.</p>
781         * @return array containing a copy of vector elements
782         */
783        double[] toArray();
784    
785        /**
786         * Returns true if any coordinate of this vector is NaN; false otherwise
787         * @return  true if any coordinate of this vector is NaN; false otherwise
788         */
789        boolean isNaN();
790    
791        /**
792         * Returns true if any coordinate of this vector is infinite and none are NaN;
793         * false otherwise
794         * @return  true if any coordinate of this vector is infinite and none are NaN;
795         * false otherwise
796         */
797        boolean isInfinite();
798    
799    }