Mercurial > hg > octave-lyh
comparison liboctave/Array.cc @ 1360:7eb93d12654c
[project @ 1995-09-05 21:51:54 by jwe]
author | jwe |
---|---|
date | Tue, 05 Sep 1995 21:51:54 +0000 |
parents | 64819a909ed7 |
children | 9f9131a8d706 |
comparison
equal
deleted
inserted
replaced
1359:a6994c934a50 | 1360:7eb93d12654c |
---|---|
31 | 31 |
32 #include <assert.h> | 32 #include <assert.h> |
33 | 33 |
34 #include "Array.h" | 34 #include "Array.h" |
35 | 35 |
36 /* | 36 // The real representation of all arrays. |
37 * The real representation of all arrays. | |
38 */ | |
39 | 37 |
40 template <class T> | 38 template <class T> |
41 ArrayRep<T>::ArrayRep (T *d, int l) | 39 ArrayRep<T>::ArrayRep (T *d, int l) |
42 { | 40 { |
43 data = d; | 41 data = d; |
94 ArrayRep<T>::elem (int n) const | 92 ArrayRep<T>::elem (int n) const |
95 { | 93 { |
96 return data[n]; | 94 return data[n]; |
97 } | 95 } |
98 | 96 |
99 /* | 97 // One dimensional array class. Handles the reference counting for |
100 * One dimensional array class. Handles the reference counting for | 98 // all the derived classes. |
101 * all the derived classes. | |
102 */ | |
103 | 99 |
104 template <class T> | 100 template <class T> |
105 Array<T>::Array (T *d, int l) | 101 Array<T>::Array (T *d, int l) |
106 { | 102 { |
107 rep = new ArrayRep<T> (d, l); | 103 rep = new ArrayRep<T> (d, l); |
329 rep->count = 1; | 325 rep->count = 1; |
330 } | 326 } |
331 return rep->data; | 327 return rep->data; |
332 } | 328 } |
333 | 329 |
334 /* | 330 // Two dimensional array class. |
335 * Two dimensional array class. | |
336 */ | |
337 | 331 |
338 template <class T> | 332 template <class T> |
339 Array2<T>::Array2 (T *d, int n, int m) : Array<T> (d, n*m) | 333 Array2<T>::Array2 (T *d, int n, int m) : Array<T> (d, n*m) |
340 { | 334 { |
341 d1 = n; | 335 d1 = n; |
586 | 580 |
587 if (--old_rep->count <= 0) | 581 if (--old_rep->count <= 0) |
588 delete old_rep; | 582 delete old_rep; |
589 } | 583 } |
590 | 584 |
591 /* | 585 // Three dimensional array class. |
592 * Three dimensional array class. | |
593 */ | |
594 | 586 |
595 template <class T> | 587 template <class T> |
596 Array3<T>::Array3 (T *d, int n, int m, int k) : Array2<T> (d, n, m*k) | 588 Array3<T>::Array3 (T *d, int n, int m, int k) : Array2<T> (d, n, m*k) |
597 { | 589 { |
598 d2 = m; | 590 d2 = m; |
724 | 716 |
725 template <class T> | 717 template <class T> |
726 void | 718 void |
727 Array3<T>::resize (int n, int m, int k) | 719 Array3<T>::resize (int n, int m, int k) |
728 { | 720 { |
729 assert (0); /* XXX FIXME XXX */ | 721 assert (0); // XXX FIXME XXX |
730 } | 722 } |
731 | 723 |
732 template <class T> | 724 template <class T> |
733 void | 725 void |
734 Array3<T>::resize (int n, int m, int k, const T& val) | 726 Array3<T>::resize (int n, int m, int k, const T& val) |
735 { | 727 { |
736 assert (0); /* XXX FIXME XXX */ | 728 assert (0); // XXX FIXME XXX |
737 } | 729 } |
738 | 730 |
739 /* | 731 // A two-dimensional array with diagonal elements only. |
740 * A two-dimensional array with diagonal elements only. | |
741 */ | |
742 | 732 |
743 template <class T> | 733 template <class T> |
744 DiagArray<T>::DiagArray (T *d, int r, int c) : Array<T> (d, r < c ? r : c) | 734 DiagArray<T>::DiagArray (T *d, int r, int c) : Array<T> (d, r < c ? r : c) |
745 { | 735 { |
746 nr = r; | 736 nr = r; |