Hello,

I have a non-squared matrix with shape (1, 25). I need to calculate element-wise `sincosd`

, but I get an error:

```
ERROR: LoadError: DimensionMismatch: matrix is not square: dimensions are (1, 25)
Stacktrace:
[1] checksquare
```

Thanks.

Hello,

I have a non-squared matrix with shape (1, 25). I need to calculate element-wise `sincosd`

, but I get an error:

```
ERROR: LoadError: DimensionMismatch: matrix is not square: dimensions are (1, 25)
Stacktrace:
[1] checksquare
```

Thanks.

`sincosd.(m)`

Did you forget the dot?

Now I get from (1, 25) matrix a 2 values.

Original matrix: Float32[135.9467 135.34145 132.87178 130.95625 130.62697 135.47206 133.18242 130.9909 130.34097 131.40732 137.59009 134.9275 133.21794 132.04019 133.11278 142.98463 139.56143 137.77008 136.17714 135.66231 145.74803 143.35954 141.51982 139.42064 137.72937]

Result of `sincosd.(M)`

: (0.6953272f0, -0.7186933f0)(0.7028803f0, -0.7113081f0)

`first.(y)`

`last.(y)`

1 Like

y = sind.(dir)

x = cosd.(dir)

Works well.

I thought the whole point of using `sincos()`

was speed, but I might be wrong.

*Edit*: *it seems this is just a convenience function for less typing*.

The result of `sincos`

is: Tuple{Float32, Float32}[(0.7559644, -0.6546127) (0.7291896, -0.68431175) (0.7192175, -0.694785) (0.71985465, -0.6941248) (0.6974216, -0.71666104) (0.69730234, -0.71677715) (0.7080669, -0.70614535) (0.71278906, -0.70137846) (0.70123, -0.7129351) (0.6571556, -0.753755) (0.6404669, -0.76798576) (0.6802382, -0.73299116) (0.6800912, -0.73312753) (0.66833895, -0.74385685) (0.61875427, -0.7855846) (0.5940008, -0.8044644) (0.6333737, -0.7738461) (0.6287631, -0.77759695) (0.6279812, -0.7782285) (0.59531444, -0.80349284) (0.5785256, -0.81566423) (0.5868729, -0.8096791) (0.5875148, -0.8092134) (0.6048421, -0.7963454) (0.5933562, -0.80494)]

But the result of `y = sind.(M), x = cosd.(M)`

are 2 matrices of the same size as the original matrix.

As indicated above you could extract those two matrices using first and last. But there is probably a more efficient way

1 Like

Does

```
x, y = sincosd.(m)
```

work?

Result of `x, y = sincosd.(M)`

: (0.6953272f0, -0.7186933f0)(0.7028803f0, -0.7113081f0)

Itâ€™s not good for me.

No, that only gets the 1st and 2nd element of an iterable, and the iterable is an array of tuples, not the tuple elements:

```
julia> z = ((1,1.1), (2,2.2), (3,3.3))
((1, 1.1), (2, 2.2), (3, 3.3))
julia> x, y = z # REPL prints the righthand expression z
((1, 1.1), (2, 2.2), (3, 3.3))
julia> x
(1, 1.1)
julia> y
(2, 2.2)
```

Elementwise `first`

, `last`

, or `getindex`

works:

```
julia> first.(z)
(1, 2, 3)
julia> last.(z)
(1.1, 2.2, 3.3)
julia> getindex.(z, 2)
(1.1, 2.2, 3.3)
```

`sincosd`

specifically is implemented as `sincosd(x) = (sind(x), cosd(x))`

in trig.jl, so if separate `sind`

and `cosd`

matrices is the goal, you save some steps doing `sind.(M)`

and `cosd.(M)`

separately.

2 Likes