Or, more conveniently,
b .= 1.0
Both of your examples needlessly create and allocate an entire new matrix on the right hand side of the assignment.
Or, more conveniently,
b .= 1.0
Both of your examples needlessly create and allocate an entire new matrix on the right hand side of the assignment.