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