| Bytes | Lang | Time | Link |
|---|---|---|---|
| 004 | Uiua | 241024T231959Z | nyxbird |
| 003 | Vyxal | 241024T224203Z | emanresu |
| 040 | Ruby 2.7 | 200803T044955Z | Razetime |
| 005 | J | 230622T063821Z | south |
| 003 | Nekomata + e | 230622T042131Z | alephalp |
| 032 | Scala | 200803T195448Z | user |
| 007 | k | 221117T002203Z | cillianr |
| 028 | Juby | 221116T222944Z | Jordan |
| 026 | Raku | 220927T163732Z | Sean |
| 047 | Haskell | 200804T190229Z | AZTECCO |
| 040 | Haskell | 220926T230159Z | xnor |
| 019 | Factor + math.matrices | 220926T212221Z | chunes |
| 041 | Google Sheets | 200807T211959Z | General |
| 086 | Java JDK | 200807T192034Z | user |
| 003 | 05AB1E | 201021T091332Z | Kevin Cr |
| 003 | Jelly | 201021T082448Z | Razetime |
| 005 | Husk | 201021T070417Z | Razetime |
| 067 | Io | 200803T012346Z | user9649 |
| 009 | Julia 1.0 | 200803T223733Z | TimD |
| 064 | C gcc | 200803T053508Z | att |
| 007 | Wolfram Mathematica | 200803T180442Z | polfosol |
| 008 | gorbitsaROM | 200803T101358Z | Noone At |
| 010 | Charcoal | 200803T092925Z | Neil |
| 005 | Japt | 200803T013115Z | AZTECCO |
| 042 | JavaScript ES6 | 200803T082559Z | Arnauld |
| 023 | R | 200803T062704Z | Robin Ry |
| 005 | Brachylog | 200803T044814Z | DLosc |
| 005 | Pip | 200803T043746Z | DLosc |
| 005 | Pyth | 200803T043226Z | Mukundan |
| 019 | Octave | 200803T033249Z | Daniel H |
| 005 | MATL | 200803T032615Z | Mukundan |
| 045 | Python 2 | 200803T012732Z | Chas Bro |
| 003 | APL Dyalog Unicode | 200803T005725Z | Bubbler |
Scala, 32 bytes
l=>l.transpose==l.map(_.map(-_))
Finally, something that Scala has a builtin for!
The function's pretty straightforward - it compares the transpose of a List[List[Int]](doesn't have to be a List, could be any Iterable) to the negative, found by mapping each list inside l and using - to make it negative.
k, 7 bytes
Similar to the APL solution. Compare (x~) original matrix against negated transpose (-+x}
{x~-+x}
J-uby, 28 bytes
Port of Razetime's Ruby answer.
:=~&(:transpose|:*&(:*&:-@))
Explanation
:=~ & (:transpose | :* & (:* & :-@))
:transpose | # Transpose input, then
:* & ( ) # Map with
:* & :-@ # Map with negate
:=~ & ( ) # Equal to input
Raku, 26 bytes
{none flat $_ »+«[Z] $_}
$_is the input matrix, in the form of a list of lists of integers.[Z] $_is the transpose of the input matrix.»+«adds the input matrix to its transpose.flatflattens the matrix into a single list of numbers.noneconverts that list of numbers into a junction which is true if and only if none of the numbers is truthy, that is, nonzero.
The none-junction is returned. It is truthy only if adding the matrix to its transpose results in a matrix containing all zeroes.
Haskell, 49 47 bytes
import Data.List
f x=x==transpose(map(0-)<$>x)
- saved 2 thanks to @Unrelated String
My first Haskell.
Function tacking a matrix and checking if input is equal to input mapped to (0-value) and transposed
Haskell, 40 bytes
(==)<*>foldr(zipWith(:).map(0-))z
z=[]:z
Uses this tip for shorter transpose and the idiom of (==)<*> to check invariance under an operation.
Factor + math.matrices, 19 bytes
[ dup flip mneg = ]
dupmake a copy of the inputfliptranspose itmnegnegate it=are they equal?
Google Sheets, 90 88 41
(Now with lambdas)
Closing parens discounted.
Named Functions (name, args, and formula text all count):
| Name | args | Formula |
|---|---|---|
P |
a, b |
a+b |
Q |
a |
MAP(a,TRANSPOSE(a),P) |
Formula:
=SUM(Q(A1:C3))
No, I cannot currently use ADD instead of P as it is not a lambda.
How it Works:
Add the matrix to its transpose. If the resulting matrix is all 0's, then the sum of all elements is 0, which means we the two are equal.
Return 0 if equal, some positive number otherwise.
Java (JDK), 89 87 86 bytes
- -2 bytes thanks to Calculuswhiz!
m->{int i=0,j,r=1;for(;++i<m.length;)for(j=0;++j<i;)r=m[i][j]!=-m[j][i]?0:r;return r;}
Returns 0 for false and 1 for true.
05AB1E, 3 bytes
ø(Q
Try it online or verify all test cases.
Explanation:
ø # Zip/transpose the (implicit) input-matrix; swapping rows/columns
( # Negate each value in this transposed matrix
Q # And check if it's equal to the (implicit) input-matrix
# (after which the result is output implicitly)
Io, 67 bytes
method(~,~map(i,\,\map(I,V,V+x at(I)at(i)))flatten unique==list(0))
Explanation
For all a[x][y], it checks whether all a[x][y]+a[y][x]==0.
method(~, // Input x.
~ map(i,\, // Map all x's rows (index i):
\ map(I,V, // Foreach the rows (index I):
V+x at(I)at(i) // x[i][I] + x[I][i]
)
) flatten // Flatten the resulting list
unique // Uniquify the list
==list(0) // Does this resulting list *only* contain the item 0?
)
C (gcc), 67 64 bytes
-3 thanks to AZTECCO
i,j;f(m,s)int**m;{for(i=j=0;i=i?:s--;)j|=m[s][--i]+m[i][s];m=j;}
Returns 0 if the matrix is antisymmetric, and a nonzero value otherewise.
Wolfram Mathematica, 20, 7 bytes
There is a built-in function for this task:
AntisymmetricMatrixQ
But one can simply write a script with less byte counts:
#==-#ᵀ&
The ᵀ character, as it is displayed in notebooks, stands for transpose. But if you copy this into tio, it won't be recognized because these characters are only supported by Mathematica notebooks.
gorbitsa-ROM, 8 bytes
r1 R A1 B0 T
This is an awful abuse of rule
Input and output can assume whatever forms are most convenient.
If input takes form of "arr[i][j] arr[j][i]", the problem becomes "is sum = 0?".
This code takes pairs of values and outputs their sum if it's not 0
Thus if you provide matrix as previously mentioned pairs, code will return some value for not-anti-symmetric ones and will not return anything for anti-symmetric ones.
r1 R A1 B0 T
r1 #store first number
R #read second number
A1 #add first number
B0 #if sum==0, jump to the beginning
T #else output the sum
Charcoal, 10 bytes
⁼θEθEθ±§λκ
Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - if the matrix is antisymmetric, nothing if not. Explanation:
Eθ Map over input matrix rows (should be columns, but it's square)
Eθ Map over input matrix rows
§λκ Cell of transpose
± Negated
⁼θ Does matrix equal its negated transpose?
Japt, 5 bytes
eUy®n
e compare input with :
Uy columns of input
®n with each element negated
Previous version ÕeËËn didn't work, corrected using the ® symbol
JavaScript (ES6), 42 bytes
Returns false for antisymmetric or true for non-antisymmetric.
m=>m.some((r,y)=>r.some((v,x)=>m[x][y]+v))
Brachylog, 5 bytes
5 bytes seems to be the right length for this (unless you're Jelly). Actually, this would be three bytes if Brachylog implicitly vectorized predicates like negation.
\ṅᵐ²?
Explanation
\ Transpose
ṅᵐ² Map negation at depth 2
? Assert that the result is the same as the input
Pip, 5 bytes
Z_=-_
A function submission; pass a nested list as its argument. Try it online!
Explanation
Z_ The argument, zipped together
= Equals
-_ The argument, negated
Pyth, 5 bytes
qC_MM
Explanation
qC_MM
q : Check if input equals
C : Transpose of
_MM : Negated input
Octave, 19 bytes
@(a)isequal(a',-a);
The semicolon doesn't need to be there, but it outputs the function otherwise, so I'll take the one-byte hit to my score for now.
Explanation
It's pretty straightforward - it checks to see if the matrix of the transpose is equal to the negative matrix
MATL, 5 bytes
!_GX=
Explanation
!_GX=
// Implicit input on top of stack
! // Replace top stack element with its transpose
_ // Replace top stack element with its negative
G // Push input onto stack
X= // Check for equality
APL (Dyalog Unicode), 3 bytes
-≡⍉
This is exactly an APLcart entry on "antisymmetric". Basically it checks if the input's negative - matches ≡ the input's transpose ⍉.