Hi!
1) It looks like two vector operations have bugs in BLT 3:
* skew(x) is defined incorrectly as a normalized mean of the absolute value of x^3, there shouldn't be an absolute value (Ex^3/s^3, not E|x|^3/s^3). This bug is present in BLT 2 as well.
* q2(x) is defined as mean(x), but should be median(x). There's no q2() in BLT 2.
2) Looking into tests/vector.tcl, I've found the following failing test [blt::vector create z_values(50)]
. Since specifying vector length as (50) or first/last indices as (1:50) was the intended way of creating preallocated vectors in BLT 2, I've tried to reimplement it for BLT 3 as well. Also, I've added options -first
and -last
(they were listed in the comments in bltVectors.c, so I assume that it's the new way to specify the range of indices).
Please, consider the attached patch with the following changes:
1) src/bltVecMath.c: fixes bugs with skew() and q2().
2) src/bltVectors.c: adds -first
and -last
options for vector creation. Also, changes the type of -length
to BLT_SWITCH_INT_POS
because the size
have type int
(so BLT_SWITCH_LONG_POS
overwrites switches.first
).
3) src/bltVectors.c: Moves parsing name(12)
and name(1:10)
to a separate function, which is called both from VectorCreateOp()
and OldVectorCreate()
.
4) src/bltVectors.c: changes size = last - first
to size = last - first + 1
on vector creation. Probably, you wanted ranges like 1:3
mean 1 2
, but this would require the respective changes in other places where ranges are acceptable (like ::vector value set 1:3 1
which currently sets values for 3 elements, and not for 2. Clearly, this change can be discussed further.
5) src/bltVectors.c: implements defining vector size and offset in [blt::vector create]
by both (23:42)
and -first 23 -last 42'.
6) src/bltVectors.c: implements
v(:)as a synonym to
v(all). It didn't work as it was before for the case of an empty vector.
7) tests/vector.tcl: fixes all the existing tests and adds a few tests for
[blt::vector create]`.