22 |
05 Aug 03 |
peter |
// $Id$ |
12 |
19 Jun 03 |
daniel |
2 |
|
570 |
05 Apr 06 |
jari |
3 |
/* |
570 |
05 Apr 06 |
jari |
Copyright (C) 2003 Daniel Dalevi, Peter Johansson |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2004 Jari Häkkinen, Peter Johansson |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
4207 |
26 Aug 22 |
peter |
Copyright (C) 2009, 2012, 2013, 2017, 2021, 2022 Peter Johansson |
570 |
05 Apr 06 |
jari |
9 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/trac/yat |
570 |
05 Apr 06 |
jari |
11 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
570 |
05 Apr 06 |
jari |
16 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
570 |
05 Apr 06 |
jari |
General Public License for more details. |
570 |
05 Apr 06 |
jari |
21 |
|
570 |
05 Apr 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
570 |
05 Apr 06 |
jari |
24 |
*/ |
570 |
05 Apr 06 |
jari |
25 |
|
2881 |
18 Nov 12 |
peter |
26 |
#include <config.h> |
2881 |
18 Nov 12 |
peter |
27 |
|
1027 |
02 Feb 08 |
peter |
28 |
#include "VectorConstView.h" |
4119 |
07 Nov 21 |
peter |
29 |
#include "MatrixBase.h" |
3595 |
21 Jan 17 |
peter |
30 |
#include "VectorView.h" |
125 |
02 Aug 04 |
peter |
31 |
|
4141 |
01 Feb 22 |
peter |
32 |
#include <cassert> |
4141 |
01 Feb 22 |
peter |
33 |
|
42 |
26 Feb 04 |
jari |
34 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
35 |
namespace yat { |
616 |
31 Aug 06 |
jari |
36 |
namespace utility { |
12 |
19 Jun 03 |
daniel |
37 |
|
12 |
19 Jun 03 |
daniel |
38 |
|
1027 |
02 Feb 08 |
peter |
39 |
VectorConstView::VectorConstView(const VectorConstView& other) |
1130 |
23 Feb 08 |
peter |
40 |
: VectorBase(), const_view_(NULL) |
686 |
16 Oct 06 |
jari |
41 |
{ |
1710 |
13 Jan 09 |
peter |
42 |
copy(other); |
686 |
16 Oct 06 |
jari |
43 |
} |
12 |
19 Jun 03 |
daniel |
44 |
|
686 |
16 Oct 06 |
jari |
45 |
|
3595 |
21 Jan 17 |
peter |
46 |
VectorConstView::VectorConstView(const VectorView& other) |
3595 |
21 Jan 17 |
peter |
47 |
: VectorBase(), const_view_(NULL) |
3595 |
21 Jan 17 |
peter |
48 |
{ |
3595 |
21 Jan 17 |
peter |
49 |
copy(other); |
3595 |
21 Jan 17 |
peter |
50 |
} |
3595 |
21 Jan 17 |
peter |
51 |
|
3595 |
21 Jan 17 |
peter |
52 |
|
1027 |
02 Feb 08 |
peter |
53 |
VectorConstView::VectorConstView(const VectorBase& other) |
1130 |
23 Feb 08 |
peter |
54 |
: VectorBase(), const_view_(NULL) |
1008 |
01 Feb 08 |
peter |
55 |
{ |
1710 |
13 Jan 09 |
peter |
56 |
copy(other); |
1008 |
01 Feb 08 |
peter |
57 |
} |
1008 |
01 Feb 08 |
peter |
58 |
|
1008 |
01 Feb 08 |
peter |
59 |
|
1027 |
02 Feb 08 |
peter |
60 |
VectorConstView::VectorConstView(const VectorBase& v, size_t offset,size_t n, |
1027 |
02 Feb 08 |
peter |
61 |
size_t stride) |
1027 |
02 Feb 08 |
peter |
62 |
: VectorBase() |
1008 |
01 Feb 08 |
peter |
63 |
{ |
1008 |
01 Feb 08 |
peter |
64 |
const_view_ = new gsl_vector_const_view( |
2687 |
27 Feb 12 |
peter |
65 |
gsl_vector_const_subvector_with_stride(v.gsl_vector_p(), |
1008 |
01 Feb 08 |
peter |
66 |
offset, stride,n)); |
1008 |
01 Feb 08 |
peter |
67 |
const_vec_ = &(const_view_->vector); |
1008 |
01 Feb 08 |
peter |
68 |
} |
1008 |
01 Feb 08 |
peter |
69 |
|
1008 |
01 Feb 08 |
peter |
70 |
|
4119 |
07 Nov 21 |
peter |
71 |
VectorConstView::VectorConstView(const MatrixBase& m, size_t i, bool row) |
1015 |
01 Feb 08 |
peter |
72 |
: VectorBase(), const_view_(NULL) |
42 |
26 Feb 04 |
jari |
73 |
{ |
2687 |
27 Feb 12 |
peter |
74 |
const_view_ = |
2687 |
27 Feb 12 |
peter |
75 |
new gsl_vector_const_view(row ? |
1008 |
01 Feb 08 |
peter |
76 |
gsl_matrix_const_row(m.gsl_matrix_p(),i) : |
1008 |
01 Feb 08 |
peter |
77 |
gsl_matrix_const_column(m.gsl_matrix_p(),i)); |
1008 |
01 Feb 08 |
peter |
78 |
const_vec_ = &(const_view_->vector); |
1008 |
01 Feb 08 |
peter |
79 |
} |
1008 |
01 Feb 08 |
peter |
80 |
|
1008 |
01 Feb 08 |
peter |
81 |
|
4141 |
01 Feb 22 |
peter |
82 |
VectorConstView::VectorConstView(const gsl_vector* v) |
4141 |
01 Feb 22 |
peter |
83 |
{ |
4141 |
01 Feb 22 |
peter |
84 |
const_view_ = |
4141 |
01 Feb 22 |
peter |
85 |
new gsl_vector_const_view(gsl_vector_const_subvector(v, 0, v->size)); |
4141 |
01 Feb 22 |
peter |
86 |
const_vec_ = &(const_view_->vector); |
4141 |
01 Feb 22 |
peter |
87 |
} |
4141 |
01 Feb 22 |
peter |
88 |
|
4141 |
01 Feb 22 |
peter |
89 |
|
4141 |
01 Feb 22 |
peter |
90 |
VectorConstView::VectorConstView(const double* v, size_t size, size_t stride) |
4141 |
01 Feb 22 |
peter |
91 |
{ |
4141 |
01 Feb 22 |
peter |
92 |
const_view_ = |
4141 |
01 Feb 22 |
peter |
93 |
new gsl_vector_const_view(gsl_vector_const_view_array_with_stride(v, |
4141 |
01 Feb 22 |
peter |
94 |
stride, |
4141 |
01 Feb 22 |
peter |
95 |
size)); |
4141 |
01 Feb 22 |
peter |
96 |
const_vec_ = &(const_view_->vector); |
4141 |
01 Feb 22 |
peter |
97 |
} |
4141 |
01 Feb 22 |
peter |
98 |
|
4141 |
01 Feb 22 |
peter |
99 |
|
1027 |
02 Feb 08 |
peter |
100 |
VectorConstView::~VectorConstView(void) |
42 |
26 Feb 04 |
jari |
101 |
{ |
1008 |
01 Feb 08 |
peter |
102 |
delete_allocated_memory(); |
42 |
26 Feb 04 |
jari |
103 |
} |
22 |
05 Aug 03 |
peter |
104 |
|
42 |
26 Feb 04 |
jari |
105 |
|
1710 |
13 Jan 09 |
peter |
106 |
void VectorConstView::copy(const VectorBase& other) |
42 |
26 Feb 04 |
jari |
107 |
{ |
3104 |
02 Nov 13 |
peter |
108 |
if (!other.gsl_vector_p()) // nothing to do |
3104 |
02 Nov 13 |
peter |
109 |
return; |
2687 |
27 Feb 12 |
peter |
110 |
const_view_ = |
2687 |
27 Feb 12 |
peter |
111 |
new gsl_vector_const_view(gsl_vector_const_subvector(other.gsl_vector_p(), |
1710 |
13 Jan 09 |
peter |
112 |
0, other.size())); |
1710 |
13 Jan 09 |
peter |
113 |
const_vec_ = &(const_view_->vector); |
1008 |
01 Feb 08 |
peter |
114 |
} |
1008 |
01 Feb 08 |
peter |
115 |
|
1008 |
01 Feb 08 |
peter |
116 |
|
1027 |
02 Feb 08 |
peter |
117 |
void VectorConstView::delete_allocated_memory(void) |
1008 |
01 Feb 08 |
peter |
118 |
{ |
1710 |
13 Jan 09 |
peter |
119 |
delete const_view_; |
1710 |
13 Jan 09 |
peter |
120 |
const_view_=NULL; |
1027 |
02 Feb 08 |
peter |
121 |
const_vec_ = NULL; |
810 |
15 Mar 07 |
jari |
122 |
} |
810 |
15 Mar 07 |
jari |
123 |
|
810 |
15 Mar 07 |
jari |
124 |
|
1710 |
13 Jan 09 |
peter |
125 |
bool VectorConstView::isview(void) const |
1710 |
13 Jan 09 |
peter |
126 |
{ |
1710 |
13 Jan 09 |
peter |
127 |
return true; |
1710 |
13 Jan 09 |
peter |
128 |
} |
1710 |
13 Jan 09 |
peter |
129 |
|
686 |
16 Oct 06 |
jari |
130 |
}}} // of namespace utility, yat, and thep |