MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction (the transpose was originally missing).
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy) if the input is a Hadamard matrix, or a matrix containing at least a zero (which is falsy) otherwise.
Try it online! Or verify all test cases.
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display
MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction.
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy) if the input is a Hadamard matrix, or a matrix containing at least a zero (which is falsy) otherwise.
Try it online! Or verify all test cases.
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display
MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction (the transpose was originally missing).
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy) if the input is a Hadamard matrix, or a matrix containing at least a zero (which is falsy) otherwise.
Try it online! Or verify all test cases.
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display
MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction.
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy) if the input is a HadamrdHadamard matrix, or a matrix containing at least a zero (which is falsy) otherwise.
Try it online! Or verify all test cases.
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display
MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction.
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy) if the input is a Hadamrd matrix, or a matrix containing at least a zero (which is falsy) otherwise.
Try it online! Or verify all test cases.
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display
MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction.
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy) if the input is a Hadamard matrix, or a matrix containing at least a zero (which is falsy) otherwise.
Try it online! Or verify all test cases.
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display
MATL, 9(削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction.
t!Y*zUGn=Y*XR~
Inputs a matrix. GivesOutputs a a matrix of ones 1 or(which is 0 for Hadamard or non-Hadamardtruthy ) if the input is a Hadamrd matrix, respectivelyor a matrix containing at least a zero (which is falsy ) otherwise.
Try it online! Try it online! Or verify all test cases verify all test cases .
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
zXR % Number ofSet non-zeros.entries Giveson nthe ifdiagonal and only if M is Hadamard
U %below Squareto 0
G % Push input~ again
n % NumberNegate ofeach entriesentry. Gives n^2
= % Equal? Implicit display
MATL, 9 bytes
Thanks to @alephalpha for a correction.
t!Y*zUGn=
Inputs a matrix. Gives 1 or 0 for Hadamard or non-Hadamard, respectively.
Try it online! Or verify all test cases
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
z % Number of non-zeros. Gives n if and only if M is Hadamard
U % Square
G % Push input again
n % Number of entries. Gives n^2
= % Equal? Implicit display
MATL, (削除) 9 (削除ここまで) 7 bytes
Thanks to @alephalpha for a correction.
t!Y*XR~
Inputs a matrix. Outputs a a matrix of ones (which is truthy ) if the input is a Hadamrd matrix, or a matrix containing at least a zero (which is falsy ) otherwise.
Try it online! Or verify all test cases .
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
! % Transpose
Y* % Matrix product. This is a scalar matrix if and only if M is Hadamard
XR % Set entries on the diagonal and below to 0
~ % Negate each entry. Implicit display