Grok 12.0.1
WaveletCommon.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2024 Grok Image Compression Inc.
3 *
4 * This source code is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License, version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This source code is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 *
17 */
18
19#pragma once
20
21namespace grk
22{
23
24template<typename T, size_t N>
25struct vec
26{
27 vec(void) : val{0} {}
28 explicit vec(T m)
29 {
30 for(size_t i = 0; i < N; ++i)
31 val[i] = m;
32 }
34 {
35 vec rc;
36 for(size_t i = 0; i < N; ++i)
37 rc.val[i] = val[i] + rhs.val[i];
38
39 return rc;
40 }
42 {
43 for(size_t i = 0; i < N; ++i)
44 val[i] += rhs.val[i];
45
46 return *this;
47 }
49 {
50 vec rc;
51 for(size_t i = 0; i < N; ++i)
52 rc.val[i] = val[i] - rhs.val[i];
53
54 return rc;
55 }
57 {
58 for(size_t i = 0; i < N; ++i)
59 val[i] -= rhs.val[i];
60
61 return *this;
62 }
63
64 constexpr static size_t NUM_ELTS = N;
65 T val[N];
66};
67
68} // namespace grk
Copyright (C) 2016-2024 Grok Image Compression Inc.
Definition ICacheable.h:20
void grk_read(const uint8_t *buffer, TYPE *value, uint32_t numBytes)
Definition BufferedStream.h:239
Definition WaveletCommon.h:26
vec operator+(const vec &rhs)
Definition WaveletCommon.h:33
static constexpr size_t NUM_ELTS
Definition WaveletCommon.h:64
vec & operator+=(const vec &rhs)
Definition WaveletCommon.h:41
vec(void)
Definition WaveletCommon.h:27
vec operator-(const vec &rhs)
Definition WaveletCommon.h:48
vec(T m)
Definition WaveletCommon.h:28
vec & operator-=(const vec &rhs)
Definition WaveletCommon.h:56
T val[N]
Definition WaveletCommon.h:65