TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
cross_product.hpp
Go to the documentation of this file.
1// Copyright (c) 2020--present, The Simons Foundation
2// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3// SPDX-License-Identifier: Apache-2.0
4// See LICENSE in the root of this distribution for details.
5
10
11#pragma once
12
13#include "../basic_array.hpp"
14#include "../concepts.hpp"
15#include "../declarations.hpp"
16#include "../macros.hpp"
18#include "../mem/policies.hpp"
19
20namespace nda::linalg {
21
33 template <Vector X, Vector Y>
35 auto cross_product(X const &x, Y const &y) {
36 EXPECTS(x.size() == 3 and y.size() == 3);
37 auto res = vector<decltype(x(0) * y(0)), nda::heap<nda::mem::common_addr_space<X, Y>>>(3);
38 res(0) = x(1) * y(2) - y(1) * x(2);
39 res(1) = -x(0) * y(2) + y(0) * x(2);
40 res(2) = x(0) * y(1) - y(0) * x(1);
41 return res;
42 }
43
44} // namespace nda::linalg
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides the generic class for arrays.
Provides concepts for the nda library.
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
basic_array< ValueType, 1, C_layout, 'V', ContainerPolicy > vector
Alias template of an nda::basic_array with rank 1 and a 'V' algebra.
auto cross_product(X const &x, Y const &y)
Compute the cross product of two 3-dimensional vectors and .
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
constexpr AddressSpace common_addr_space
Get common address space for a number of given nda::Array types.
heap_basic< mem::mallocator< AdrSp > > heap
Alias template of the nda::heap_basic policy using an nda::mem::mallocator.
Definition policies.hpp:52
Macros used in the nda library.
Defines various memory handling policies.