TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
ger.hpp
Go to the documentation of this file.
1// Copyright (c) 2019--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
14#include "./tools.hpp"
15#include "../concepts.hpp"
18#include "../macros.hpp"
20#include "../traits.hpp"
21
22#ifndef NDA_HAVE_DEVICE
23#include "../device.hpp"
24#endif // NDA_HAVE_DEVICE
25
26namespace nda::blas {
27
32
53 template <MemoryVector X, MemoryVector Y, MemoryMatrix M>
55 void ger(get_value_t<X> alpha, X const &x, Y const &y, M &&m) { // NOLINT (temporary views are allowed here)
56 // for C-layout arrays/views, call ger with the transpose and swap x and y
57 if constexpr (has_C_layout<M>) {
58 ger(alpha, y, x, transpose(m));
59 return;
60 }
61
62 // check the dimensions of the input/output arrays/views
63 EXPECTS(m.extent(0) == x.size());
64 EXPECTS(m.extent(1) == y.size());
65
66 // arrays/views must be BLAS compatible
67 EXPECTS(m.indexmap().min_stride() == 1);
68
69 // perform actual library call
71#if defined(NDA_HAVE_DEVICE)
72 device::ger(m.extent(0), m.extent(1), alpha, x.data(), x.indexmap().strides()[0], y.data(), y.indexmap().strides()[0], m.data(), get_ld(m));
73#else
75#endif
76 } else {
77 f77::ger(m.extent(0), m.extent(1), alpha, x.data(), x.indexmap().strides()[0], y.data(), y.indexmap().strides()[0], m.data(), get_ld(m));
78 }
79 }
80
82
83} // namespace nda::blas
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides a C++ interface for various BLAS routines.
Provides concepts for the nda library.
Provides GPU and non-GPU specific functionality.
auto transpose(A &&a)
Transpose the memory layout of an nda::MemoryArray or an nda::expr_call.
constexpr bool have_same_value_type_v
Constexpr variable that is true if all types in As have the same value type as A0.
Definition traits.hpp:186
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
Definition traits.hpp:182
static constexpr bool has_C_layout
Constexpr variable that is true if the given nda::Array type has a C memory layout.
Definition tools.hpp:65
int get_ld(A const &a)
Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for LAPACK calls.
Definition tools.hpp:102
void ger(get_value_t< X > alpha, X const &x, Y const &y, M &&m)
Interface to the BLAS ger and geru routine.
Definition ger.hpp:55
static constexpr bool have_compatible_addr_space
Constexpr variable that is true if all given types have compatible address spaces.
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
void compile_error_no_gpu()
Trigger a compilation error in case GPU specific functionality is used without configuring the projec...
Definition device.hpp:36
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Definition traits.hpp:92
Provides definitions of various layout policies.
Provides functions to transform the memory layout of an nda::basic_array or nda::basic_array_view.
Macros used in the nda library.
Provides various traits and utilities for the BLAS interface.
Provides type traits for the nda library.