ALP User Documentation 0.7.alpha
Algebraic Programming User Documentation
Loading...
Searching...
No Matches
norm.hpp
Go to the documentation of this file.
1
2/*
3 * Copyright 2021 Huawei Technologies Co., Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
34#ifndef _H_GRB_ALGORITHMS_NORM
35#define _H_GRB_ALGORITHMS_NORM
36
37#include <graphblas.hpp>
38
39#include <cmath> // for std::sqrt
40
41
42namespace grb {
43
44 namespace algorithms {
45
71 template<
72 Descriptor descr = descriptors::no_operation, class Ring,
73 typename InputType, typename OutputType,
74 Backend backend, typename Coords
75 >
76 RC norm2( OutputType &x,
78 const Ring &ring = Ring(),
79 const typename std::enable_if<
80 std::is_floating_point< OutputType >::value,
81 void >::type * const = nullptr
82 ) {
83 RC ret = grb::dot< descr >( x, y, y, ring );
84 if( ret == SUCCESS ) {
85 x = sqrt( x );
86 }
87 return ret;
88 }
89
90 }
91}
92
93#endif // end ``_H_GRB_ALGORITHMS_NORM''
94
A GraphBLAS vector.
Definition: vector.hpp:64
The main header to include in order to use the ALP/GraphBLAS API.
Backend
A collection of all backends.
Definition: backends.hpp:46
RC norm2(OutputType &x, const Vector< InputType, backend, Coords > &y, const Ring &ring=Ring(), const typename std::enable_if< std::is_floating_point< OutputType >::value, void >::type *const =nullptr)
Provides a generic implementation of the 2-norm computation.
Definition: norm.hpp:76
static constexpr Descriptor no_operation
Indicates no additional pre- or post-processing on any of the GraphBLAS function arguments.
Definition: descriptors.hpp:63
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:450
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
@ SUCCESS
Indicates the primitive has executed successfully.
Definition: rc.hpp:54
unsigned int Descriptor
Descriptors indicate pre- or post-processing for some or all of the arguments to an ALP/GraphBLAS cal...
Definition: descriptors.hpp:54