cavis/libnd4j/include/helpers/hhSequence.h
raver119 63fa3c2ef3
libnd4j polishing (#273)
* initial set of include changes

Signed-off-by: raver119 <raver119@gmail.com>

* one more tweak

Signed-off-by: raver119 <raver119@gmail.com>

* few more rearrangements

Signed-off-by: raver119 <raver119@gmail.com>

* few more rearrangements

Signed-off-by: raver119 <raver119@gmail.com>

* few more rearrangements

Signed-off-by: raver119 <raver119@gmail.com>

* cuda includes rearrangements

Signed-off-by: raver119 <raver119@gmail.com>

* java update

Signed-off-by: raver119 <raver119@gmail.com>

* = namespace changed to sd
- few CMake variables renamed with SD_ prefix

Signed-off-by: raver119 <raver119@gmail.com>

* java update

Signed-off-by: raver119 <raver119@gmail.com>

* LoopKind minor fix

Signed-off-by: raver119 <raver119@gmail.com>

* few more changes

Signed-off-by: raver119 <raver119@gmail.com>

* few more changes

Signed-off-by: raver119 <raver119@gmail.com>

* few more changes

Signed-off-by: raver119 <raver119@gmail.com>

* sanitizer is optional now

Signed-off-by: raver119 <raver119@gmail.com>

* dev tests updated

Signed-off-by: raver119 <raver119@gmail.com>

* few more changes

Signed-off-by: raver119 <raver119@gmail.com>

* last update

Signed-off-by: raver119 <raver119@gmail.com>

* java update

Signed-off-by: raver119 <raver119@gmail.com>
2020-03-02 12:49:41 +03:00

101 lines
2.2 KiB
C++

/*******************************************************************************
* Copyright (c) 2015-2018 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/
//
// Created by Yurii Shyrma on 02.01.2018
//
#ifndef LIBND4J_HHSEQUENCE_H
#define LIBND4J_HHSEQUENCE_H
#include "array/NDArray.h"
namespace sd {
namespace ops {
namespace helpers {
class HHsequence {
public:
/*
* matrix containing the Householder vectors
*/
NDArray _vectors;
/*
* vector containing the Householder coefficients
*/
NDArray _coeffs;
/*
* shift of the Householder sequence
*/
int _shift;
/*
* length of the Householder sequence
*/
int _diagSize;
/*
* type of sequence, type = 'u' (acting on columns, left) or type = 'v' (acting on rows, right)
*/
char _type;
/*
* constructor
*/
HHsequence(const NDArray& vectors, const NDArray& coeffs, const char type);
/**
* this method mathematically multiplies input matrix on Householder sequence from the left H0*H1*...Hn * matrix
*
* matrix - input matrix to be multiplied
*/
template <typename T>
void _mulLeft(NDArray& matrix);
void mulLeft(NDArray& matrix);
NDArray getTail(const int idx) const;
template <typename T>
void _applyTo(NDArray& dest);
void applyTo(NDArray& dest);
FORCEINLINE int rows() const;
};
//////////////////////////////////////////////////////////////////////////
FORCEINLINE int HHsequence::rows() const {
return _type == 'u' ? _vectors.sizeAt(0) : _vectors.sizeAt(1);
}
}
}
}
#endif //LIBND4J_HHSEQUENCE_H