Skip to content

Commit

Permalink
added ones function
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjharrison committed Oct 16, 2023
1 parent 5f96b4d commit b7e8639
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/madness/tensor/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,14 @@ MADNESS_PRAGMA_GCC(diagnostic pop)
return (-t)+=x;
}

/// Returns a new tensor filled with ones
template <typename T>
Tensor<T> ones(long n) {
Tensor<T> result = Tensor<T>(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
Expand Down

0 comments on commit b7e8639

Please sign in to comment.