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-2024 Simons Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0.txt
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Authors: Thomas Hahn, Miguel Morales, Nils Wentzell
16
22#pragma once
23
25#include "./tools.hpp"
26#include "../concepts.hpp"
27#include "../device.hpp"
29#include "../traits.hpp"
30
31namespace nda::blas {
32
47 template <typename X>
48 requires(MemoryVector<X> or is_conj_array_expr<X>)
49 void scal(get_value_t<X> alpha, X &&x) { // NOLINT (temporary views are allowed here)
50 static_assert(is_blas_lapack_v<get_value_t<X>>, "Error in nda::blas::scal: Value type of vector is incompatible with blas");
51
52 if constexpr (mem::on_host<X>) {
53 f77::scal(x.size(), alpha, x.data(), x.indexmap().strides()[0]);
54 } else {
55#if defined(NDA_HAVE_DEVICE)
56 device::scal(x.size(), alpha, x.data(), x.indexmap().strides()[0]);
57#else
59#endif
60 }
61 }
62
63} // 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:192
void scal(get_value_t< X > alpha, X &&x)
Interface to the BLAS scal routine.
Definition scal.hpp:49
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:47
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Definition traits.hpp:102
Provides various traits and utilities for the BLAS interface.
Provides type traits for the nda library.