libMesh/libmesh: coverage diff

Base 8c3130 Head #4343 6ea38c
Total Total +/- New
Rate 66.47% 66.45% -0.02% 100.00%
Hits 80271 80271 - 45
Misses 40494 40524 +30 0
Filename Stmts Miss Cover
include/numerics/type_n_tensor.h +30 +30 -6.05%
TOTAL +30 +30 -0.02%
code
coverage unchanged
code
coverage increased
code
coverage decreased
+
line added or modified

include/numerics/type_n_tensor.h

60  
61  
62  
63 +
64  
65 +
66  
67  
68 +
69  
70 +
71  
72  
73 +
74  
75  
76  
    libmesh_not_implemented();
  }

  TypeNTensor(const TypeVector<T> &) : _coords(std::vector<T>(int_pow(LIBMESH_DIM, N)))
  {
    libmesh_not_implemented();
  }

  TypeNTensor(const TypeTensor<T> &) : _coords(std::vector<T>(int_pow(LIBMESH_DIM, N)))
  {
    libmesh_not_implemented();
  }

  TypeNTensor(const TypeNTensor<N, T> & TN) : _coords(TN._coords) {}

  /**
   * Constructor from the flattened coefficients, ordered as \p _coords.
80  
81  
82  
83 +
84  
85 +
86 +
87  
88  
89  
    libmesh_assert_equal_to(vec.size(), std::size_t(int_pow(LIBMESH_DIM, N)));
  }

  TypeNTensor & operator=(const TypeNTensor<N, T> & TN)
  {
    _coords = TN._coords;
    return *this;
  }

  operator TypeVector<T>() const
115  
116  
117  
118 +
119  
120 +
121 +
122 +
123 +
124 +
125 +
126 +
127  
128  
129  
  /**
   * \returns A writable proxy for the \f$ i^{th} \f$ slice of the tensor.
   */
  TypeNTensor<N - 1, T> slice(const unsigned int i)
  {
    libmesh_assert_less(i, LIBMESH_DIM);
    TypeNTensor<N - 1, T> slice;
    unsigned int slice_size = int_pow(LIBMESH_DIM, N - 1);
    slice._coords.resize(slice_size);
    for (unsigned int j = 0; j < slice_size; j++)
      slice._coords[j] = _coords[i * slice_size + j];
    return slice;
  }

  /**
155  
156  
157  
158 +
159  
160 +
161 +
162 +
163  
164  
165  
   * Add to this tensor.
   */
  template <typename T2>
  const TypeNTensor<N, T> & operator+=(const TypeNTensor<N, T2> & other)
  {
    unsigned int size = int_pow(LIBMESH_DIM, N);
    for (unsigned int i = 0; i < size; i++)
      _coords[i] += other._coords[i];
    return *this;
  }

168  
169  
170  
171 +
172  
173 +
174 +
175 +
176 +
177 +
178 +
179  
180  
181  
   */
  template <typename T2>
  TypeNTensor<N, typename CompareTypes<T, T2>::supertype>
  operator-(const TypeNTensor<N, T2> & other) const
  {
    TypeNTensor<N, typename CompareTypes<T, T2>::supertype> subtract;
    unsigned int size = int_pow(LIBMESH_DIM, N);
    subtract._coords.resize(size);
    for (unsigned int i = 0; i < size; i++)
      subtract._coords[i] = _coords[i] - other._coords[i];
    return subtract;
  }

  /**
210  
211  
212  
213 +
214  
215 +
216 +
217 +
218 +
219 +
220 +
221  
222  
223  
  typename std::enable_if<
    ScalarTraits<Scalar>::value,
    TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype>>::type
  operator * (const Scalar factor) const
  {
    TypeNTensor<N, typename CompareTypes<T, Scalar>::supertype> multiplied;
    unsigned int size = int_pow(LIBMESH_DIM, N);
    multiplied._coords.resize(size);
    for (unsigned int i = 0; i < size; i++)
      multiplied._coords[i] = factor * _coords[i];
    return multiplied;
  }

  /**
280  
281  
282  
283 +
284  
285  
286  
   * \returns The Frobenius norm of the tensor, i.e. the square-root of
   * the sum of the elements squared.
   */
  auto norm() const -> decltype(std::norm(T())) { return std::sqrt(norm_sq()); }

  /**
   * \returns The Frobenius norm of the tensor squared, i.e. the sum of the
288  
289  
290  
291 +
292 +
293 +
294 +
295 +
296  
297  
298  
299  
300  
301 +
302  
303 +
304 +
305 +
306 +
307  
308  
309  
   */
  auto norm_sq() const
  {
    unsigned int size = int_pow(LIBMESH_DIM, N);
    Real sum = 0.;
    for (unsigned int i = 0; i < size; i++)
      sum += TensorTools::norm_sq(_coords[i]);
    return sum;
  }

  /**
   * Set all entries of the tensor to 0.
   */
  void zero()
  {
    unsigned int size = int_pow(LIBMESH_DIM, N);
    for (unsigned int i = 0; i < size; i++)
      _coords[i] = T(0);
  }

  /**
   * \returns \p true if two tensors are equal, \p false otherwise.