LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
std_matrix.h
Go to the documentation of this file.
1// Copyright 2021 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef DEEPLIMA_APPS_STD_MATRIX_H
7#define DEEPLIMA_APPS_STD_MATRIX_H
8
9#include <iostream>
10#include <memory>
11
12template <class T>
14{
15public:
16 StdVector(const std::vector<T>& input)
17 : m_vector(input) { }
18
19 inline T get(size_t idx) const
20 {
21 assert(idx < m_vector.size());
22 return m_vector[idx];
23 }
24
25protected:
26 const std::vector<T>& m_vector;
27};
28
29template <class T>
31{
32public:
33
35 {
36 }
37
38 StdMatrix(std::shared_ptr< std::vector< std::vector<T> > > input) : m_tensor(input)
39 {
40 }
41
43 }
44
47 }
48
50 // std::cerr << "Matrix Destroyed!\n";
51 }
52
53 inline size_t get(size_t time, size_t feat) const
54 {
55 assert(feat < std::numeric_limits<size_t>::max());
56 assert(time < std::numeric_limits<size_t>::max());
57
58 return m_tensor[feat][time];
59 }
60
61 void copy(const StdMatrix<T>& m){
63 }
64
66 inline size_t size() const
67 {
68 return m_tensor.size();
69 }
70
75 inline size_t dim() const
76 {
77 assert(m_tensor.size() > 0);
78 return m_tensor[0].size();
79 }
80
81 inline void resize(size_t new_size)
82 {
83 m_tensor.resize(new_size);
84 }
85
86 inline std::vector<T>& operator[](size_t index)
87 {
88 return m_tensor[index];
89 }
90
91 std::vector<std::vector<T>> m_tensor;
92protected:
93
94};
95
96#endif
size_t size() const
Return the number of elements in this matrix.
Definition std_matrix.h:66
size_t dim() const
Return the dimension of this matrix's vectors (their size).
Definition std_matrix.h:75
StdMatrix(const StdMatrix &m)
Definition std_matrix.h:42
StdMatrix & operator=(const StdMatrix &m)
Definition std_matrix.h:45
size_t get(size_t time, size_t feat) const
Definition std_matrix.h:53
void copy(const StdMatrix< T > &m)
Definition std_matrix.h:61
std::vector< T > & operator[](size_t index)
Definition std_matrix.h:86
void resize(size_t new_size)
Definition std_matrix.h:81
std::vector< std::vector< T > > m_tensor
Definition std_matrix.h:91
StdMatrix(std::shared_ptr< std::vector< std::vector< T > > > input)
Definition std_matrix.h:38
StdVector(const std::vector< T > &input)
Definition std_matrix.h:16
const std::vector< T > & m_vector
Definition std_matrix.h:26
T get(size_t idx) const
Definition std_matrix.h:19