TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
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
"
17
#include "
../mem/address_space.hpp
"
18
#include "
../mem/policies.hpp
"
19
20
namespace
nda::linalg {
21
37
template
<Vector X, Vector Y>
38
requires
(
nda::mem::have_host_compatible_addr_space<X, Y>
)
39
auto
cross_product
(X
const
&x, Y
const
&y) {
40
EXPECTS(x.size() == 3 and y.size() == 3);
41
auto
res =
vector
<
decltype
(x(0) * y(0)),
nda::heap
<
nda::mem::common_addr_space<X, Y>
>>(3);
42
res(0) = x(1) * y(2) - y(1) * x(2);
43
res(1) = -x(0) * y(2) + y(0) * x(2);
44
res(2) = x(0) * y(1) - y(0) * x(1);
45
return
res;
46
}
47
48
}
// namespace nda::linalg
address_space.hpp
Provides definitions and type traits involving the different memory address spaces supported by nda.
basic_array.hpp
Provides the generic class for arrays.
concepts.hpp
Provides concepts for the nda library.
declarations.hpp
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
nda::vector
basic_array< ValueType, 1, C_layout, 'V', ContainerPolicy > vector
Alias template of an nda::basic_array with rank 1 and a 'V' algebra.
Definition
declarations.hpp:145
nda::linalg::cross_product
auto cross_product(X const &x, Y const &y)
Compute the vector cross product.
Definition
cross_product.hpp:39
nda::mem::have_host_compatible_addr_space
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
Definition
address_space.hpp:173
nda::mem::common_addr_space
constexpr AddressSpace common_addr_space
Get common address space for a number of given nda::Array types.
Definition
address_space.hpp:111
nda::heap
heap_basic< mem::mallocator< AdrSp > > heap
Alias template of the nda::heap_basic policy using an nda::mem::mallocator.
Definition
policies.hpp:52
macros.hpp
Macros used in the nda library.
policies.hpp
Defines various memory handling policies.
nda
linalg
cross_product.hpp
Generated by
1.17.0