Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ overwrites anyway, and the memory stays warm in cache: `x + y` on 1 024
elements goes from 2.6 µs to 0.38 µs, and `sqrt(x*y + x)` on 256 Ki from
1.18 ms to 0.39 ms. Those two figures compare Go with Go. The NumPy figures once
quoted beside them came from multicore runs. On one core, the allocating
forms are about 3× slower than NumPy, while the preallocated `*Into` forms tie
with it ([docs/perf.md](docs/perf.md), #118). ⚠ An array allocated from the workspace
forms are about 3.4–3.8× slower than NumPy (10⁵ float64), while the
preallocated `*Into` forms are within 7% of it ([docs/perf.md](docs/perf.md), #118). ⚠ An array allocated from the workspace
is invalid after `Reset`; `Detach` is how a result leaves it. The `*Into`
methods (`AddInto`, `SqrtInto`, …) remain the way to reuse one named buffer.

Expand Down Expand Up @@ -149,8 +149,16 @@ keep NaN bits exactly; for the others a signalling NaN may come back quieted):
on 10⁵ float64 on one core of cfarm420 they went from 243–464 µs to 70–81 µs
([docs/perf.md](docs/perf.md), *Since the table*).

**Behaviour change in the next release (a MINOR): `Round` rounds halves to
even.** It is now `np.round` with no decimals, on every dtype (float64, float32
**Behaviour change in the next release (a MINOR): `Ravel` and `Real` return
views, as NumPy does.** `Ravel` of an array whose elements are one row-major
run (a contiguous array, or a contiguous slice of one) shares its storage
(`numpy.ravel`), and `Real` of a non-complex array is the array itself
(`numpy.real`). A `Set` through the result therefore changes the original.
`Ravel` of a non-contiguous array still copies, and `Real` of a complex array
is still a new float array. For an independent array use `Flatten` (always a
copy, as `numpy.flatten`) or `Copy`. Until v0.43.1 both always copied.

**Behaviour change in v0.43.0: `Round` rounds halves to even.** It is now `np.round` with no decimals, on every dtype (float64, float32
and each part of a complex number): `Round` of 0.5, 1.5, 2.5 and -0.5 gives 0, 2,
2 and -0. Until v0.42.0 it rounded halves away from zero (1, 2, 3, -1), and
that behaviour is now `RoundHalfAway` (`math.Round`, the scalar path, the same
Expand Down
8 changes: 6 additions & 2 deletions arith.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,14 @@ func whereTyped(cond, t, f *Array, shape []int) *Array {
}

// Real returns the real part of the elements: a float array of the same
// precision for a complex array, a copy otherwise (as numpy.real).
// precision for a complex array (a copy), and for any other dtype a VIEW of
// the array itself, as numpy.real returns: it shares the storage, so a Set
// through the result changes the array too. Use Copy for an independent array.
func (a *Array) Real() *Array {
if !a.dtype.IsComplex() {
return a.Copy()
r := a.view(append([]int(nil), a.shape...), append([]int(nil), a.strides...), a.offset)
r.weak = a.weak
return r
}
return a.AsType(complexPart(a.dtype))
}
Expand Down
518 changes: 259 additions & 259 deletions docs/perf-table.md

Large diffs are not rendered by default.

Loading
Loading