Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/SpValProxy_bones.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2011-2012 Ryan Curtin | |
2 // | |
3 // This Source Code Form is subject to the terms of the Mozilla Public | |
4 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
6 | |
7 //! \addtogroup SpValProxy | |
8 //! @{ | |
9 | |
10 /** | |
11 * Sparse value proxy class, meant to prevent 0s from being added to sparse | |
12 * matrices. T1 should be either SpMat or SpSubview, and if it's not, bad news | |
13 * is probably coming. This class only uses T1::add_element() and | |
14 * T1::delete_element(). | |
15 */ | |
16 template<typename T1> | |
17 class SpValProxy | |
18 { | |
19 public: | |
20 | |
21 typedef typename T1::elem_type eT; // Convenience typedef | |
22 | |
23 friend class SpMat<eT>; | |
24 friend class SpSubview<eT>; | |
25 | |
26 /** | |
27 * Create the sparse value proxy. | |
28 * Otherwise, pass a pointer to a reference of the value. | |
29 */ | |
30 arma_inline SpValProxy(uword row, uword col, T1& in_parent, eT* in_val_ptr = NULL); | |
31 | |
32 //! For swapping operations. | |
33 arma_inline SpValProxy& operator=(const SpValProxy& rhs); | |
34 template<typename T2> | |
35 arma_inline SpValProxy& operator=(const SpValProxy<T2>& rhs); | |
36 | |
37 //! Overload all of the potential operators. | |
38 | |
39 //! First, the ones that could modify a value. | |
40 arma_inline SpValProxy& operator=(const eT rhs); | |
41 arma_inline SpValProxy& operator+=(const eT rhs); | |
42 arma_inline SpValProxy& operator-=(const eT rhs); | |
43 arma_inline SpValProxy& operator*=(const eT rhs); | |
44 arma_inline SpValProxy& operator/=(const eT rhs); | |
45 | |
46 arma_inline SpValProxy& operator++(); | |
47 arma_inline SpValProxy& operator--(); | |
48 arma_inline eT operator++(const int); | |
49 arma_inline eT operator--(const int); | |
50 | |
51 //! This will work for any other operations that do not modify a value. | |
52 arma_inline operator eT() const; | |
53 | |
54 | |
55 private: | |
56 | |
57 // Deletes the element if it is zero. Does not check if val_ptr == NULL! | |
58 arma_inline arma_hot void check_zero(); | |
59 | |
60 uword row; | |
61 uword col; | |
62 | |
63 eT* val_ptr; | |
64 | |
65 T1& parent; // We will call this object if we need to insert or delete an element. | |
66 }; | |
67 | |
68 | |
69 | |
70 //! @} |