cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-236281%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236281%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%BE%9E%E6%96%87%E4%BB%B6%E4%BE%86%E7%9C%8B%EF%BC%8C%20*%20%E9%81%8B%E7%AE%97%E5%AD%90%E5%B0%87%E5%9F%B7%E8%A1%8C%E5%8F%89%E7%A9%8D%EF%BC%8C%E8%80%8C%20%3B*%20%E5%B0%87%E5%9F%B7%E8%A1%8C%E9%BB%9E%E7%A9%8D%E3%80%82%20%E6%88%91%E6%83%B3%E4%BD%BF%E7%94%A8%E5%8F%89%E7%A9%8D%E4%BE%86%E7%A2%BA%E5%AE%9A%E4%B8%80%E5%B0%8D%E5%B7%B2%E7%9F%A5%E5%90%91%E9%87%8F%E7%9A%84%E6%B3%95%E5%90%91%E5%90%91%E9%87%8F%EF%BC%8C%E5%A6%82%E4%B8%8B%E6%89%80%E7%A4%BA%EF%BC%9A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ep1%20%3D%20%5B1%2C%202%2C%204%5D%3B%0Ap2%20%3D%20%5B2%2C%201%2C%204%5D%3B%0Ap3%20%3D%20%5B2%2C%202%2C%204%5D%3B%0A%0Av1%20%3D%20p3%20-%20p1%3B%0Av2%20%3D%20p2%20-%20p1%3B%0A%0AxProd%20%3D%20v1*v2%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E3%20%E5%80%8B%E9%BB%9E%E5%AE%9A%E7%BE%A9%E4%B8%80%E5%80%8B%E5%B9%B3%E9%9D%A2%EF%BC%8C%E5%BE%9E%E9%80%99%E4%BA%9B%E9%BB%9E%E5%8F%96%E5%BE%97%E7%9A%84%E5%85%A9%E5%80%8B%E5%90%91%E9%87%8F%E5%81%9A%E5%90%8C%E6%A8%A3%E7%9A%84%E4%BA%8B%E6%83%85%EF%BC%8C%E5%8F%89%E7%A9%8D%E6%87%89%E8%A9%B2%E7%B5%A6%E5%87%BA%E8%A9%B2%E5%B9%B3%E9%9D%A2%E7%9A%84%E6%B3%95%E5%90%91%E9%87%8F%E3%80%82%20%E5%95%8F%E9%A1%8C%E4%BC%BC%E4%B9%8E%E6%98%AF%E7%9B%B8%E4%B9%98%E7%9A%84%E5%85%A9%E5%80%8B%E7%9F%A9%E9%99%A3%EF%BC%88v1%20%E5%92%8C%20v2%EF%BC%89%E7%9A%84%E7%B6%AD%E5%BA%A6%E4%B8%8D%E4%B8%80%E8%87%B4%20-%20nRows(v1)%20%E6%87%89%E7%AD%89%E6%96%BC%20nCols(v2)%E3%80%82%20%E6%88%91%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%E7%9A%84%E7%B0%A1%E5%8C%96%E5%85%AC%E5%BC%8F%E6%89%8B%E5%8B%95%E5%AF%A6%E7%8F%BE%E6%AD%A4%E6%93%8D%E4%BD%9C%EF%BC%8C%E4%BD%86%E6%9C%89%E4%BA%BA%E7%9F%A5%E9%81%93%E5%A6%82%E4%BD%95%E4%BB%A5%E4%B8%8D%E5%90%8C%E7%9A%84%E6%96%B9%E5%BC%8F%E6%A0%BC%E5%BC%8F%E5%8C%96%E5%AE%83%E4%BB%A5%E4%BD%BF%E7%94%A8%E7%9F%A9%E9%99%A3%E4%B9%98%E6%B3%95%E5%97%8E%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-611821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-611821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%80%A7%E8%83%BD%E8%BC%83%E5%B7%AE%E4%B8%A6%E4%B8%8D%E4%BB%A4%E4%BA%BA%E9%A9%9A%E8%A8%9D......%E6%84%9F%E8%AC%9D%E6%8F%92%E5%85%A5%E7%AC%A6%E8%99%9F%E8%AA%BF%E6%95%B4%E3%80%82%20%E6%88%91%E7%84%A1%E6%84%8F%E4%B8%AD%E6%BC%8F%E6%8E%89%E4%BA%86%E3%80%8C%E7%AC%A6%E8%99%9F%E6%A3%8B%E7%9B%A4%E3%80%8D%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E5%9C%A8%E6%88%91%E7%9C%8B%E4%BE%86%EF%BC%8C%E9%80%99%E6%98%AF%E2%80%9C%E5%83%85%E5%83%85%E5%9B%A0%E7%82%BA%E4%BD%A0%E5%8F%AF%E4%BB%A5%EF%BC%8C%E4%B8%A6%E4%B8%8D%E6%84%8F%E5%91%B3%E8%91%97%E4%BD%A0%E6%87%89%E8%A9%B2%E2%80%9D%E9%81%A9%E7%94%A8%E7%9A%84%E6%83%85%E6%B3%81%E4%B9%8B%E4%B8%80...%20%7B%E9%85%B7%E3%80%81%E6%9C%89%E8%B6%A3%E3%80%81%E7%B0%A1%E7%9F%AD%7D%E4%B8%A6%E4%B8%8D%E5%8B%9D%E9%81%8E%7B%E5%8F%AF%E7%90%86%E8%A7%A3%E3%80%81%E5%8F%AF%E7%B6%AD%E8%AD%B7%E3%80%81%E5%BF%AB%E9%80%9F%7D%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-611720%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-611720%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3552%22%20target%3D%22_blank%22%3E%40brady_brady%3C%2FA%3E%E6%B6%BC%E7%88%BD%E7%9A%84%EF%BC%81%20%E5%A6%82%E6%9E%9C%E6%82%A8%E8%A6%81%E4%BD%BF%E7%94%A8%E5%AE%83%EF%BC%8C%E5%89%87%E9%9C%80%E8%A6%81%E9%80%B2%E8%A1%8C%E8%AA%BF%E6%95%B4%EF%BC%9A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%20i%20%3D%201%3B%0A%20j%20%3D%20-1%3B%0A%20J(%203%2C%201%2C%20(j%20*%3D%20-1)%20*%20Det(%20(v1%20%7C%7C%20v2)%5BRemove(%20%5B1%2C%202%2C%203%5D%2C%20i%2B%2B%20)%2C%200%5D%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3C%2FCODE%3E%3CA%20href%3D%22https%3A%2F%2Fmathinsight.org%2Fcross_product_formula%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmathinsight.org%2Fcross_product_formula%3C%2FA%3E%E9%A1%AF%E7%A4%BA%E4%B8%AD%E9%96%93%E5%85%83%E7%B4%A0%E5%A6%82%E4%BD%95%E9%9C%80%E8%A6%81%E7%82%BA%E8%B2%A0%E6%95%B8%E3%80%82%E5%9C%A8%E4%B8%8A%E9%9D%A2%EF%BC%8Cj%20%E6%9C%83%E4%BA%A4%E6%9B%BF%E7%AC%A6%E8%99%9F%20(1%2C%20-1%2C%201)%EF%BC%8Ci%20%E6%9C%83%E5%A2%9E%E5%8A%A0%20(1%2C%202%2C%203)%E3%80%82%20J(...)%20%E5%87%BD%E6%95%B8%E6%9C%89%E4%B8%80%E5%80%8B%E9%9A%B1%E5%BC%8F%E5%BE%AA%E7%92%B0%EF%BC%8C%E7%94%A8%E6%96%BC%E8%A8%88%E7%AE%97%E6%AF%8F%E5%80%8B%E5%85%83%E7%B4%A0%E7%9A%84%E7%AC%AC%E4%B8%89%E5%80%8B%E5%8F%83%E6%95%B8%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E7%9B%B4%E6%8E%A5%E4%BF%AE%E6%AD%A3%E7%9A%84%E5%85%AC%E5%BC%8F%E7%82%BA%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F11962%22%20target%3D%22_blank%22%3E%40klk%3C%2FA%3E%E9%80%9F%E5%BA%A6%E5%A4%A7%E7%B4%84%E6%8F%90%E9%AB%98%E4%BA%86%203%20%E5%80%8D%EF%BC%8C%E4%B8%A6%E4%B8%94%E6%9B%B4%E5%AE%B9%E6%98%93%E7%90%86%E8%A7%A3%E5%A4%A7%E7%B4%84%20N%20%E5%80%8D%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%B8%AC%E8%A9%A6%E7%A8%8B%E5%BC%8F%E7%A2%BC%E3%80%82%3C%2FP%3E%0A%3CDIV%20class%3D%22lia-spoiler-container%22%3E%3CA%20class%3D%22lia-spoiler-link%22%20href%3D%22%23%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3E%E7%9C%8B%E6%9B%B4%E5%A4%9A...%3C%2FA%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CBR%20%2F%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ev1%20%3D%20%5B0%2C%200%2C%201%5D%3B%0Av2%20%3D%20%5B0%2C%201%2C%200%5D%3B%0A%0Astart%20%3D%20HP%20Time()%3B%0AFor(%20t%20%3D%201%2C%20t%20%26lt%3B%201e6%2C%20t%20%2B%3D%201%2C%0A%20i%20%3D%201%3B%0A%20j%20%3D%20-1%3B%0A%20J(%203%2C%201%2C%20(j%20*%3D%20-1)%20*%20Det(%20(v1%20%7C%7C%20v2)%5BRemove(%20%5B1%2C%202%2C%203%5D%2C%20i%2B%2B%20)%2C%200%5D%20)%20)%3B%0A)%3B%0Astop%20%3D%20HP%20Time()%3B%0AShow(%20(stop%20-%20start)%20%2F%201e6%20)%3B%2F%2F9.3s%0A%0A%0Astart%20%3D%20HP%20Time()%3B%0AFor(%20t%20%3D%201%2C%20t%20%26lt%3B%201e6%2C%20t%20%2B%3D%201%2C%0A%20Matrix(%20%7Bv1%5B2%5D%20*%20v2%5B3%5D%20-%20v1%5B3%5D%20*%20v2%5B2%5D%2C%20v1%5B3%5D%20*%20v2%5B1%5D%20-%20v1%5B1%5D%20*%20v2%5B3%5D%2C%20v1%5B1%5D%20*%20v2%5B2%5D%20-%20v1%5B2%5D%20*%20v2%5B1%5D%7D%20)%0A)%3B%0Astop%20%3D%20HP%20Time()%3B%0AShow(%20(stop%20-%20start)%20%2F%201e6%20)%3B%2F%2F3.2s%0A%0A%0AFor(%20q%20%3D%201%2C%20q%20%26lt%3B%2010000%2C%20q%20%2B%3D%201%2C%0A%20v1%20%3D%20J(%203%2C%201%2C%20Random%20Uniform(%20-1%2C%201%20)%20)%3B%0A%20v2%20%3D%20J(%203%2C%201%2C%20Random%20Uniform(%20-1%2C%201%20)%20)%3B%0A%20If(%0A%20%20All(%0A%20%20%20Round(%20Matrix(%20%7Bv1%5B2%5D%20*%20v2%5B3%5D%20-%20v1%5B3%5D%20*%20v2%5B2%5D%2C%20v1%5B3%5D%20*%20v2%5B1%5D%20-%20v1%5B1%5D%20*%20v2%5B3%5D%2C%20v1%5B1%5D%20*%20v2%5B2%5D%20-%20v1%5B2%5D%20*%20v2%5B1%5D%7D%20)%2C%2010%20)%20%2F%2F%0A%20%20%20%3D%3D%20%2F%2F%0A%20%20%20(i%20%3D%201%3B%20j%20%3D%20-1%20%3B%20Round(%20J(%203%2C%201%2C%20(j%20*%3D%20-1)%20*%20Det(%20(v1%20%7C%7C%20v2)%5BRemove(%20%5B1%2C%202%2C%203%5D%2C%20i%2B%2B%20)%2C%200%5D%20)%20)%2C%2010%20)%20%3B%20)%20%2F%2F%0A%20%20)%20%3D%3D%200%2F%2F%0A%20%2C%20%2F%2F%0A%20%20Throw(%20Char(%20q%20)%20)%0A%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%E5%A5%87%E6%80%AA%E7%9A%84%E6%98%AF%EF%BC%8C%E5%9B%9B%E6%8D%A8%E4%BA%94%E5%85%A5%E5%88%B0%2011%20%E4%BD%8D%E6%9C%89%E6%99%82%E7%84%A1%E6%B3%95%E5%8C%B9%E9%85%8D%E7%B5%90%E6%9E%9C%E3%80%82%20%E5%8F%AF%E8%83%BD%E5%B9%BE%E4%B9%8E%E5%85%B1%E7%B7%9A%E5%90%91%E9%87%8F%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3Ev1%20%3D%20%5B0%2C%200%2C%201%5D%3B%20v2%20%3D%20%5B0%2C%201%2C%200%5D%3B%E9%96%8B%E5%A7%8B%20%3D%20HP%20%E6%99%82%E9%96%93()%3B%20For(%20t%20%3D%201%2C%20t%20%26lt%3B%201e6%2C%20t%20%2B%3D%201%2C%20i%20%3D%201%3B%20j%20%3D%20-1%3B%20J(%203%2C%201%2C%20(j%20*%3D%20-1)%20*%20Det(%20(v1%20%7C%7C%20v2)%5B%E5%88%AA%E9%99%A4(%20%5B%201%2C%202%2C%203%5D%2C%20i%2B%2B%20)%2C%200%5D%20)%20)%3B%20)%3B%E5%81%9C%E6%AD%A2%3D%E7%94%9F%E5%91%BD%E5%80%BC%E6%99%82%E9%96%93()%3B%20Show(%20(%E5%81%9C%E6%AD%A2%20-%20%E9%96%8B%E5%A7%8B)%20%2F%201e6%20)%3B%2F%2F9.3s%E9%96%8B%E5%A7%8B%20%3D%20HP%20Time()%3B%20For(%20t%20%3D%201%2C%20t%20%26lt%3B%201e6%2C%20t%20%2B%3D%201%2C%20%E7%9F%A9%E9%99%A3(%20%7Bv1%5B2%5D%20*%20v2%5B3%5D%20-%20v1%5B3%5D%20*%20v2%5B2%5D%2C%20v1%5B3%5D%20*%20v2%5B1%5D%20-%20v1%5B%201%5D%20*%20v2%5B3%5D%2C%20v1%5B1%5D%20*%20v2%5B2%5D%20-%20v1%5B2%5D%20*%20v2%5B1%5D%7D%20)%20)%3B%E5%81%9C%E6%AD%A2%3D%E7%94%9F%E5%91%BD%E5%80%BC%E6%99%82%E9%96%93()%3B%20Show(%20(stop%20-%20start)%20%2F%201e6%20)%3B%2F%2F3.2s%20For(%20q%20%3D%201%2C%20q%20%26lt%3B%2010000%2C%20q%20%2B%3D%201%2C%20v1%20%3D%20J(%203%2C%201%2C%20%E9%9A%A8%E6%A9%9F%E5%9D%87%E5%8B%BB(%20-1%2C%201%20)%20)%3B%20v2%20%3D%20J(%203%2C%201%2C%20%E9%9A%A8%E6%A9%9F%E5%9D%87%E5%8B%BB(%20-1%2C%201%20)%20)%3B%20If(%20All(%20Round(%20%E7%9F%A9%E9%99%A3(%20%7Bv1%5B2%5D%20*%20v2%5B3%5D%20-%20v1%5B3%5D%20*%20v2%5B2%5D%2C%20v1%5B3%5D%20*%20v2%5B1%5D%20-%20v1%5B1%5D%20*%20v2%5B3%5D%2C%20v1%5B1%5D%20*%20v2%5B2%5D%20-%20v1%5B2%5D%20*%20v2%5B1%5D%7D%20)%2C%2010%20)%20%2F%2F%20%3D%3D%20%2F%2F%20(i%20%3D%201%3B%20j%20%3D%20-1%20%3B%20Round(%20J(%203%2C%201%2C%20(j%20*%3D%20-1)%20*%20Det(%20(v1%20%7C%7C%20v2)%5B%E5%88%AA%E9%99%A4(%20%5B1%2C%202%2C%203%5D%2C%20i%2B%2B%20)%2C%200%5D%20)%20)%2C%2010%20)%20%3B%20)%20%2F%2F%20)%20%3D%3D%200%2F%2F%20%2C%20%2F%2F%20Throw(%20Char(%20q%20)%20)%20)%3B%20)%3B%E5%A5%87%E6%80%AA%E7%9A%84%E6%98%AF%EF%BC%8C%E5%9B%9B%E6%8D%A8%E4%BA%94%E5%85%A5%E5%88%B0%2011%20%E4%BD%8D%E6%9C%89%E6%99%82%E7%84%A1%E6%B3%95%E5%8C%B9%E9%85%8D%E7%B5%90%E6%9E%9C%E3%80%82%20%E5%8F%AF%E8%83%BD%E5%B9%BE%E4%B9%8E%E5%85%B1%E7%B7%9A%E5%90%91%E9%87%8F%E3%80%82%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-611656%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-611656%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%A5%BD%E5%90%A7%EF%BC%8C%E5%BE%A9%E6%B4%BB%E7%9A%84%E6%AE%AD%E5%B1%8D%E6%8A%93%E4%BD%8F%E6%88%91%E4%BA%86%E3%80%82%20%E9%80%99%E6%98%AF%E4%B8%80%E7%A8%AE%E9%80%8F%E9%81%8E%E8%A1%8C%E5%88%97%E5%BC%8F%E4%BE%86%E5%81%9A%E5%88%B0%E9%80%99%E4%B8%80%E9%BB%9E%E7%9A%84%E6%96%B9%E6%B3%95%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F982%22%20target%3D%22_blank%22%3E%40Craige_Hales%3C%2FA%3E%E6%8F%90%E5%8F%8A%E3%80%82%20%E5%AE%83%E5%BE%88%E7%9F%AD%EF%BC%8C%E4%BD%86%E6%88%91%E4%B8%8D%E7%9F%A5%E9%81%93......%E5%AE%83%E4%B8%8D%E6%98%AF%E5%BE%88%E7%B0%A1%E5%96%AE%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EcrossP%20%3D%20Function(%20%7Bx%2C%20y%2C%20i%20%3D%201%7D%2C%0A%20Return(%20J(%203%2C%201%2C%20Det(%20(x%20%7C%7C%20y)%5BRemove(%20%5B1%2C%202%2C%203%5D%2C%20i%2B%2B%20)%2C%200%5D%20)%20)%20)%0A)%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E5%8D%B3%EF%BC%8C%E4%BD%BF%E7%94%A8%E6%9C%80%E5%88%9D%E6%8F%90%E4%BE%9B%E7%9A%84%E6%95%B8%E6%93%9A%EF%BC%9A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22brady_brady_0-1678770863902.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22brady_brady_0-1678770863902.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22brady_brady_0-1678770863902.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F50994iC68731CC95838C56%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22brady_brady_0-1678770863902.png%22%20alt%3D%22brady_brady_0-1678770863902.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-610312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-610312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%BE%88%E6%8A%B1%E6%AD%89%E6%81%A2%E5%BE%A9%E9%80%99%E5%80%8B%E6%AE%AD%E5%B1%8D%E7%B7%9A%E7%A8%8B%EF%BC%8C%E4%BD%86%E9%80%99%E8%A3%A1%E7%9A%84%E7%AC%AC%E4%BA%8C%E5%80%8B%E5%85%83%E7%B4%A0%E6%9C%89%E4%B8%80%E5%80%8B%E7%AC%A6%E8%99%9F%E9%8C%AF%E8%AA%A4%E3%80%82%E6%88%91%E7%9B%B8%E4%BF%A1%E6%87%89%E8%A9%B2%E6%98%AF%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EMatrix(%0A%20%20%7Bv1%5B2%5D%20*%20v2%5B3%5D%20-%20v1%5B3%5D%20*%20v2%5B2%5D%2C%20v1%5B3%5D%20*%20v2%5B1%5D%20-%20v1%5B1%5D%20*%20v2%5B3%5D%2C%20v1%5B1%5D%20*%20v2%5B2%5D%20-%20v1%5B2%5D%20*%20v2%5B1%5D%7D%3CBR%20%2F%3E)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%E5%8F%AA%E6%98%AF%E6%83%B3%E6%8A%8A%E9%80%99%E5%80%8B%E7%95%99%E5%9C%A8%E9%80%99%E8%A3%A1%E4%BE%9B%E5%85%B6%E4%BB%96%E4%BA%BA%E5%BF%AB%E9%80%9F%E8%A4%87%E8%A3%BD%E8%B2%BC%E4%B8%8A%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236315%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236315%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%AC%9D%E8%AC%9Dcwillden%EF%BC%8C%E9%80%99%E5%9F%BA%E6%9C%AC%E4%B8%8A%E5%B0%B1%E6%98%AF%E6%88%91%E6%89%80%E5%AF%A6%E7%8F%BE%E7%9A%84%E3%80%82%20%E5%AE%83%E7%A2%BA%E5%AF%A6%E5%B0%8D%E6%88%91%E6%9C%89%E7%94%A8%EF%BC%8C%E5%9B%A0%E7%82%BA%E6%88%91%E5%8F%AA%E9%97%9C%E5%BF%83%203D%20%E5%90%91%E9%87%8F%EF%BC%8C%E4%BD%86%E6%88%91%E5%BE%88%E9%A9%9A%E8%A8%9D%E9%80%99%E4%B8%8D%E6%98%AF%E5%85%A7%E5%BB%BA%E5%87%BD%E6%95%B8%E3%80%82%20%E6%88%91%E5%B0%87%E6%8A%8A%E9%80%99%E5%80%8B%E5%95%8F%E9%A1%8C%E6%9A%AB%E6%99%82%E6%93%B1%E7%BD%AE%E4%B8%80%E4%B8%8B%EF%BC%8C%E7%9C%8B%E7%9C%8B%E6%98%AF%E5%90%A6%E6%9C%89%E4%BA%BA%E7%9F%A5%E9%81%93%E9%80%99%E7%A8%AE%E6%96%B9%E6%B3%95%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236298%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236298%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E5%B8%8C%E6%9C%9B%E6%9C%89%E4%BA%BA%E6%83%B3%E5%87%BA%E4%B8%80%E5%80%8B%E8%81%B0%E6%98%8E%E7%9A%84%E6%96%B9%E6%B3%95%E4%BE%86%E5%81%9A%E5%88%B0%E9%80%99%E4%B8%80%E9%BB%9E%E3%80%82%20det()%20%E5%87%BD%E6%95%B8%E5%AF%86%E5%88%87%E7%9B%B8%E9%97%9C%EF%BC%8C%E4%BD%86%E6%88%91%E4%B8%8D%E6%98%8E%E7%99%BD%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20det(3x3%20%E7%9F%A9%E9%99%A3)%20%E4%BE%86%E5%82%B3%E5%9B%9E%E5%A4%9A%E5%80%8B%E6%A8%99%E9%87%8F%E5%80%BC%E3%80%82%20%E6%88%91%E8%AA%8D%E7%82%BA%E4%BD%A0%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%20det(2x2%20sub-matrix)%20%E4%B8%89%E6%AC%A1%EF%BC%8C%E4%BD%86%E6%88%91%E8%AA%8D%E7%82%BA%E7%9B%B4%E6%8E%A5%E7%9A%84%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FCross_product%23Mnemonic%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EXYZY%3C%2FA%3E%E6%96%B9%E6%B3%95%E6%9B%B4%E7%B0%A1%E5%96%AE%E4%B8%94%E5%90%8C%E6%A8%A3%E5%BF%AB%E9%80%9F%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%B0%87%E5%AE%83%E7%94%A8%E6%96%BC%203D%20%E5%A0%B4%E6%99%AF%E4%B8%AD%E7%9A%84%E8%A1%A8%E9%9D%A2%E6%B3%95%E7%B7%9A%EF%BC%8C%E5%85%B6%E4%B8%AD%E6%9C%89%E4%B8%80%E4%BA%9B%20JSL%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FUncharted%2FCustom-Visualization%2Fba-p%2F191559%22%20target%3D%22_blank%22%3E%20https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FUncharted%2FCustom-Visualization%2Fba-p%2F191559%3C%2FA%3E%20%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236294%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E5%A6%82%E4%BD%95%E8%A8%88%E7%AE%97%E5%90%91%E9%87%8F%E5%8F%89%E7%A9%8D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236294%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%A6%82%E6%9E%9C%E6%82%A8%E5%8F%AA%E8%99%95%E7%90%86%203x1%EF%BC%88%E6%88%96%201x3%EF%BC%89%E5%90%91%E9%87%8F%EF%BC%8C%E9%82%A3%E9%BA%BC%E6%88%91%E8%AA%8D%E7%82%BA%E8%A8%88%E7%AE%97%E6%95%88%E7%8E%87%E6%88%96%E5%84%AA%E9%9B%85%E4%B8%A6%E4%B8%8D%E6%98%AF%E5%A4%AA%E9%87%8D%E8%A6%81%E3%80%82%E9%80%99%E8%B6%B3%E5%A4%A0%E4%BA%86%E5%97%8E%EF%BC%9F%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ecross_prod%20%3D%20function(%7Bv1%2C%20v2%7D%2C%0A%20matrix(%7Bv1%5B2%5D*v2%5B3%5D%20-%20v1%5B3%5D*v2%5B2%5D%2C%20v1%5B1%5D*v2%5B3%5D%20-%20v1%5B3%5D*v2%5B1%5D%2C%20v1%5B1%5D*v2%5B2%5D%20-%20v1%5B2%5D*v2%5B1%5D%7D)%3B%0A)%3B%0A%0Across_prod(v1%2C%20v2)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
CaseyL
Level II

How to calculate Vector Cross Product

From the documentation it looks like the * operator will perform a cross product and ;* will perform a dot product. I want to use a cross product to determine the vector normal to a pair of known vectors like this:

 

p1 = [1, 2, 4];
p2 = [2, 1, 4];
p3 = [2, 2, 4];

v1 = p3 - p1;
v2 = p2 - p1;

xProd = v1*v2;

 3 points define a plane, two vectors taken from those points do the same, the cross-product should give the normal vector of that plane. The problem seems to be that the dimensions of the two matrices being multiplied (v1 and v2) do not agree -- nRows(v1) should equal nCols(v2). I can implement this manually with a simplified formula for vector cross products but does anyone know how to format this differently to work with matrix multiplication?

7 REPLIES 7
cwillden
Super User (Alumni)

Re: How to calculate Vector Cross Product

If you're only ever dealing 3x1 (or 1x3) vectors, then I would think computational efficiency or elegance is not too important.  Would this be sufficient?

cross_prod = function({v1, v2},
	matrix({v1[2]*v2[3] - v1[3]*v2[2], v1[1]*v2[3] - v1[3]*v2[1], v1[1]*v2[2] - v1[2]*v2[1]});
);

cross_prod(v1, v2);
-- Cameron Willden
Craige_Hales
Super User

Re: How to calculate Vector Cross Product

I hope someone comes up with a clever way to do this. The det() function is closely related, but I don't understand how to use det(3x3 matrix) to get back more than a scalar value. I think you could use det(2x2 sub-matrix) three times, but I think the straight-forward xyzzy approach is simpler and just as fast.

I use it for the surface normals in 3D scenes, there is some JSL in https://community.jmp.com/t5/Uncharted/Custom-Visualization/ba-p/191559 .

Craige
CaseyL
Level II

Re: How to calculate Vector Cross Product

Thanks cwillden, this is essentially what  I have implemented. It does work for me since I am only concerned with 3D vectors, but I am supprised this isn't a built in function. I'm going to leave this open for a bit to see if anyone else knows of such a way. 

klk
klk
Level III

Re: How to calculate Vector Cross Product

Sorry for reviving this zombie thread, but there is a sign error in the second element here.  I believe it should be

Matrix(
		{v1[2] * v2[3] - v1[3] * v2[2], v1[3] * v2[1] - v1[1] * v2[3], v1[1] * v2[2] - v1[2] * v2[1]}
)

Just want to leave this here for anyone else who comes along for a quick copy-paste.

Re: How to calculate Vector Cross Product

Well, the revived zombie caught me. Here is a way to do it via determinants as @Craige_Hales mentioned. It is short, but I don't know... it isn't very simple.

 

crossP = Function( {x, y, i = 1},
	Return( J( 3, 1, Det( (x || y)[Remove( [1, 2, 3], i++ ), 0] ) ) )
);

 

i.e., using the originally-supplied data:

brady_brady_0-1678770863902.png

 

Craige_Hales
Super User

Re: How to calculate Vector Cross Product

@brady_brady  Cool! It needs a tweak if you are going to use it:

	i = 1;
	j = -1;
	J( 3, 1, (j *= -1) * Det( (v1 || v2)[Remove( [1, 2, 3], i++ ), 0] ) );

 https://mathinsight.org/cross_product_formula shows how the middle element needs to be negative.  Above, j will alternate sign (1, -1, 1), and i increases (1, 2, 3). The J(...) function has an implicit loop that evaluates the 3rd argument for each element.

 

The straight forward corrected formula from @klk  is about 3 times faster and about N times easier to understand.

 

Test code.

View more...

v1 = [0, 0, 1];
v2 = [0, 1, 0];

start = HP Time();
For( t = 1, t < 1e6, t += 1,
	i = 1;
	j = -1;
	J( 3, 1, (j *= -1) * Det( (v1 || v2)[Remove( [1, 2, 3], i++ ), 0] ) );
);
stop = HP Time();
Show( (stop - start) / 1e6 );//9.3s


start = HP Time();
For( t = 1, t < 1e6, t += 1,
	Matrix( {v1[2] * v2[3] - v1[3] * v2[2], v1[3] * v2[1] - v1[1] * v2[3], v1[1] * v2[2] - v1[2] * v2[1]} )
);
stop = HP Time();
Show( (stop - start) / 1e6 );//3.2s


For( q = 1, q < 10000, q += 1,
	v1 = J( 3, 1, Random Uniform( -1, 1 ) );
	v2 = J( 3, 1, Random Uniform( -1, 1 ) );
	If(
		All(
			Round( Matrix( {v1[2] * v2[3] - v1[3] * v2[2], v1[3] * v2[1] - v1[1] * v2[3], v1[1] * v2[2] - v1[2] * v2[1]} ), 10 ) //
			== //
			(i = 1; j = -1 ; Round( J( 3, 1, (j *= -1) * Det( (v1 || v2)[Remove( [1, 2, 3], i++ ), 0] ) ), 10 ) ; ) //
		) == 0//
	, //
		Throw( Char( q ) )
	);
);
Curiously, rounding to 11 places occasionally fails to match results. Probably nearly collinear vectors.

Craige

Re: How to calculate Vector Cross Product

The inferior performance doesn't surprise... thanks for inserting the sign adjustment. I omitted the "sign checkerboard" inadvertently.

 

IMO this is one of those instances where "just because you can, doesn't mean you should" applies... {cool, fun, short} doesn't outweigh {understandable, maintainable, speedy}.