rotr90(A)

rotr90(A)

Rotate matrix A right 90 degrees.

Examples

  1. Rotate a 2x2 matrix:

    julia> A = [1 2; 3 4];
    julia> rotr90(A)
    2×2 Array{Int64,2}:
    3  1
    4  2

    This example rotates the 2x2 matrix A right 90 degrees.

  2. Rotate a 3x3 matrix:

    julia> B = [1 2 3; 4 5 6; 7 8 9];
    julia> rotr90(B)
    3×3 Array{Int64,2}:
    7  4  1
    8  5  2
    9  6  3

    It rotates the 3x3 matrix B right 90 degrees.

  3. Rotate a 4x4 matrix:
    julia> C = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
    julia> rotr90(C)
    4×4 Array{Int64,2}:
    13   9  5  1
    14  10  6  2
    15  11  7  3
    16  12  8  4

    It rotates the 4x4 matrix C right 90 degrees.

Common mistake example:

julia> D = [1 2; 3 4; 5 6];
julia> rotr90(D)
ERROR: DimensionMismatch("array could not be reshaped to match target dimension")

In this example, the input matrix D is not square, resulting in a dimension mismatch error. The rotr90 function requires a square matrix as input. Make sure to provide a square matrix to rotr90 to avoid such errors.

Rotate a matrix right 90 degrees:

julia> A = [1 2 3; 4 5 6; 7 8 9];
julia> rotr90(A)
3×3 Matrix{Int64}:
 7  4  1
 8  5  2
 9  6  3

This example rotates the matrix A right 90 degrees.

Rotate a matrix right multiple times:

julia> A = [1 2 3; 4 5 6; 7 8 9];
julia> rotr90(A, 2)
3×3 Matrix{Int64}:
 9  8  7
 6  5  4
 3  2  1

It rotates the matrix A right 90 degrees twice.

Handle edge cases:

julia> A = [1 2; 3 4];
julia> rotr90(A, 4)
2×2 Matrix{Int64}:
 1  2
 3  4

It correctly handles the case where k is zero or a multiple of four.

Common mistake example:

julia> A = [1 2 3; 4 5 6; 7 8 9];
julia> rotr90(A, -1)
ERROR: DomainError with -1:
The value of `k` must be non-negative.

In this example, a negative value for k is provided, which results in a DomainError. It's important to ensure that k is a non-negative integer to avoid such errors.

See Also

Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: