TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
scal.hpp
Go to the documentation of this file.
1// Copyright (c) 2023--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"
16#include "../device.hpp"
18#include "../traits.hpp"
19
20namespace nda::blas {
21
36 template <typename X>
37 requires(MemoryVector<X> or is_conj_array_expr<X>)
38 void scal(get_value_t<X> alpha, X &&x) { // NOLINT (temporary views are allowed here)
39 static_assert(is_blas_lapack_v<get_value_t<X>>, "Error in nda::blas::scal: Value type of vector is incompatible with blas");
40
41 if constexpr (mem::on_host<X>) {
42 f77::scal(x.size(), alpha, x.data(), x.indexmap().strides()[0]);
43 } else {
44#if defined(NDA_HAVE_DEVICE)
45 device::scal(x.size(), alpha, x.data(), x.indexmap().strides()[0]);
46#else
48#endif
49 }
50 }
51
52} // 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.
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:181
static constexpr bool is_conj_array_expr
Constexpr variable that is true if the given type is a conjugate lazy expression.
Definition tools.hpp:41
void scal(get_value_t< X > alpha, X &&x)
Interface to the BLAS scal routine.
Definition scal.hpp:38
static constexpr bool on_host
Constexpr variable that is true if all given types have a Host address space.
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:91
Provides various traits and utilities for the BLAS interface.
Provides type traits for the nda library.