GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — multi_array: outer product for vectors · hmenke/cpp-patterns@ee53178

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • multi_array
    • multi_array.hpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎multi_array/multi_array.hpp‎

Copy file name to clipboardExpand all lines: multi_array/multi_array.hpp
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class multi_array {
204204
meta::all<std::is_convertible<Idx, size_type>::value...>::value,
205205
"type mismatch");
206206
return
207-
#if !defined(NDEBUG) || defined(__CUDACC__)
207+
#if !defined(NDEBUG) && !defined(__CUDACC__)
208208
meta::check_bounds<sizeof...(idx)-1, N...>{}(idx...),
209209
#endif
210210
m_data[meta::linearized_index<sizeof...(idx)-1, N...>{}(idx...)];
@@ -222,7 +222,7 @@ class multi_array {
222222
meta::all<std::is_convertible<Idx, size_type>::value...>::value,
223223
"type mismatch");
224224
return
225-
#if !defined(NDEBUG) || defined(__CUDACC__)
225+
#if !defined(NDEBUG) && !defined(__CUDACC__)
226226
meta::check_bounds<sizeof...(idx) - 1, N...>{}(idx...),
227227
#endif
228228
m_data[meta::linearized_index<sizeof...(idx) - 1, N...>{}(idx...)];
@@ -243,5 +243,16 @@ class multi_array {
243243
}
244244
};
245245

246+
template <typename T, std::size_t M, std::size_t N>
247+
DEVICE_FUNC multi_array<T,M,N> outer(multi_array<T,M> const & a, multi_array<T,N> const & b) {
248+
multi_array<T,M,N> c;
249+
for (std::size_t i = 0; i < M; ++i) {
250+
for (std::size_t j = 0; j < N; ++j) {
251+
c(i,j) = a(i) * b(j);
252+
}
253+
}
254+
return c;
255+
}
256+
246257
#undef CXX14_CONSTEXPR
247258
#undef DEVICE_FUNC

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.