• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adc-connect / adcc / 5362537629

pending completion
5362537629

push

github

mfherbst
Bump version: 0.15.16 → 0.15.17

1487 of 2318 branches covered (64.15%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

7130 of 9470 relevant lines covered (75.29%)

191956.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.5
/libadcc/Tensor.cc
1
//
2
// Copyright (C) 2018 by the adcc authors
3
//
4
// This file is part of adcc.
5
//
6
// adcc is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published
8
// by the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// adcc is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with adcc. If not, see <http://www.gnu.org/licenses/>.
18
//
19

20
#include "Tensor.hh"
21

22
namespace libadcc {
23

24
Tensor::Tensor(std::shared_ptr<const AdcMemory> adcmem_ptr, std::vector<AxisInfo> axes)
1,636,505✔
25
      : m_size(1), m_shape(axes.size(), 0), m_axes{axes}, m_adcmem_ptr{adcmem_ptr} {
1,636,505✔
26
  for (size_t i = 0; i < axes.size(); ++i) {
6,441,357✔
27
    m_shape[i] = axes[i].size();
4,804,852✔
28
    m_size *= axes[i].size();
4,804,852✔
29
  }
30
}
1,636,505✔
31

32
std::vector<std::string> Tensor::subspaces() const {
9,118✔
33
  std::vector<std::string> ret;
9,118✔
34
  for (const auto& ax : axes()) {
34,814✔
35
    ret.push_back(ax.label);
25,696✔
36
  }
37
  return ret;
9,118✔
38
}
×
39

40
std::string Tensor::space() const {
×
41
  std::string ret = "";
×
42
  for (const auto& ax : axes()) ret.append(ax.label);
×
43
  return ret;
×
44
}
×
45

46
void Tensor::fill(scalar_type value) {
166,946✔
47
  const std::string alphabet = "abcdefgh";
166,946✔
48
  if (ndim() > alphabet.size()) {
166,946✔
49
    throw not_implemented_error(
×
50
          "zeros_like and empty_like only implemented up to tensor dimensionality 8.");
×
51
  }
52
  std::string mask = alphabet.substr(0, ndim());
166,946✔
53
  set_mask(mask, value);
166,946✔
54
}
166,946✔
55

56
std::shared_ptr<Tensor> Tensor::zeros_like() const {
69,630✔
57
  auto res = empty_like();
69,630✔
58
  res->fill(0.0);
69,630✔
59
  return res;
69,630✔
60
}
×
61

62
std::shared_ptr<Tensor> Tensor::ones_like() const {
26✔
63
  auto res = empty_like();
26✔
64
  res->fill(1.0);
26✔
65
  return res;
26✔
66
}
×
67

68
std::shared_ptr<Tensor> make_tensor_zero(std::shared_ptr<Symmetry> symmetry) {
72,386✔
69
  auto res = make_tensor(symmetry);
72,386✔
70
  res->fill(0.0);
72,386✔
71
  return res;
72,386✔
72
}
×
73

74
}  // namespace libadcc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc