Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Timeline for Is there a single straight line in the matrix?

Current License: CC BY-SA 4.0

24 events
when toggle format what by license comment
Jun 19, 2021 at 18:17 history edited theorist CC BY-SA 4.0
deleted 4 characters in body
Jun 19, 2021 at 9:28 history edited theorist CC BY-SA 4.0
deleted 54 characters in body
Jun 19, 2021 at 9:17 history edited theorist CC BY-SA 4.0
deleted 3 characters in body
Jun 19, 2021 at 7:27 history edited theorist CC BY-SA 4.0
added 19 characters in body
Jun 19, 2021 at 6:51 history edited theorist CC BY-SA 4.0
added 995 characters in body
Jun 19, 2021 at 6:47 comment added theorist @Nitrodon Nice catch! I've modified my code to account for the type of case you identified.
Jun 19, 2021 at 6:45 history edited theorist CC BY-SA 4.0
added 995 characters in body
Jun 17, 2021 at 17:17 history edited theorist CC BY-SA 4.0
added 188 characters in body
Jun 17, 2021 at 13:55 comment added Nitrodon Fails on {{1, 1, 0, 0}, {1, 1, 0 ,0}, {0, 0, 0, 0}, {0, 0, 0, 0}, which has operator norm 2.
Jun 17, 2021 at 12:27 comment added ZaMoC Nice answer! I'm glad I helped. (no need for credits..) ;)
Jun 17, 2021 at 12:10 history edited theorist CC BY-SA 4.0
added 289 characters in body
Jun 17, 2021 at 12:08 comment added theorist @ZaMoC Thanks, I wasn't quite sure how to set that up with tio.run. If you don't mind, I'll add your link to my answer, crediting you.
Jun 17, 2021 at 12:04 comment added ZaMoC here are all test cases: Try it online!
Jun 17, 2021 at 12:00 comment added MarcMush right sorry, it seems the correct equivalent in Julia would be opnorm
Jun 17, 2021 at 11:56 comment added theorist Flatten@SingularValueDecomposition@m = {1/Sqrt[2], 0, -(1/Sqrt[ 2]), 1/Sqrt[2], 0, 1/Sqrt[2], 0, 1, 0, Sqrt[2], 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}; hence Norm@m returns the largest value, which is Sqrt[2]. Thus (Norm@m)^2 = 2. But m is 3x3, and 2!=3, so my funciton returns False.
Jun 17, 2021 at 11:56 comment added theorist @MarcMush I tried your test matrix, and it correctly returned False. "norm" seems to means something different in Julia—according to discourse.julialang.org/t/performance-of-norm-function/14709/9, it instead computes the Frobenius norm. In Mathematica, when Norm is applied to a matrix, it does a singular value decomposition, and then selects the element with the maximum value. So, for your matrix m= {{1, 0, 0}, {1, 0, 0}, {0, 1, 0}}, [continued]
Jun 17, 2021 at 11:28 comment added MarcMush I don't have mathematica but it seems like this only counts if there is the right amount of 1s Try it online with Julia!
Jun 17, 2021 at 8:26 history edited theorist CC BY-SA 4.0
added 62 characters in body
Jun 17, 2021 at 6:43 history edited theorist CC BY-SA 4.0
deleted 81 characters in body
Jun 17, 2021 at 6:29 comment added Bubbler I think it should be fine to strip the if statement entirely (giving true or false).
Jun 17, 2021 at 6:26 history edited theorist CC BY-SA 4.0
added 3 characters in body
Jun 17, 2021 at 6:04 history edited theorist CC BY-SA 4.0
added 179 characters in body
Jun 17, 2021 at 5:51 history edited theorist CC BY-SA 4.0
edited body
Jun 17, 2021 at 5:40 history answered theorist CC BY-SA 4.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /