From b7e86391488975d13e2d638852bca706d41e5bdb Mon Sep 17 00:00:00 2001 From: "Robert J. Harrison" Date: Mon, 16 Oct 2023 13:46:44 -0400 Subject: [PATCH] added ones function --- src/madness/tensor/tensor.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/madness/tensor/tensor.h b/src/madness/tensor/tensor.h index e68ca3d46ff..38a0888f713 100644 --- a/src/madness/tensor/tensor.h +++ b/src/madness/tensor/tensor.h @@ -1955,6 +1955,14 @@ MADNESS_PRAGMA_GCC(diagnostic pop) return (-t)+=x; } + /// Returns a new tensor filled with ones + template + Tensor ones(long n) { + Tensor result = Tensor(1,&n,false); + UNARY_OPTIMIZED_ITERATOR(T,result,*_p0 = 1.0); + return result; + } + /// Returns a new contiguous tensor that is a deep copy of the input /// \ingroup tensor