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%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236281%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%83%89%E3%82%AD%E3%83%A5%E3%83%A1%E3%83%B3%E3%83%88%E3%81%AB%E3%82%88%E3%82%8B%E3%81%A8%E3%80%81*%20%E6%BC%94%E7%AE%97%E5%AD%90%E3%81%AF%E5%A4%96%E7%A9%8D%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%97%E3%80%81%3B*%20%E3%81%AF%E3%83%89%E3%83%83%E3%83%88%E7%A9%8D%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B%E3%82%88%E3%81%86%E3%81%A7%E3%81%99%E3%80%82%20%E6%AC%A1%E3%81%AE%E3%82%88%E3%81%86%E3%81%AB%E3%80%81%E5%A4%96%E7%A9%8D%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%80%81%E6%97%A2%E7%9F%A5%E3%81%AE%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%AE%E3%83%9A%E3%82%A2%E3%81%AB%E5%9E%82%E7%9B%B4%E3%81%AA%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%82%92%E6%B1%BA%E5%AE%9A%E3%81%97%E3%81%9F%E3%81%84%E3%81%A8%E8%80%83%E3%81%88%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%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%E3%81%A4%E3%81%AE%E7%82%B9%E3%81%8C%E5%B9%B3%E9%9D%A2%E3%82%92%E5%AE%9A%E7%BE%A9%E3%81%97%E3%80%81%E3%81%9D%E3%82%8C%E3%82%89%E3%81%AE%E7%82%B9%E3%81%8B%E3%82%89%E5%8F%96%E5%BE%97%E3%81%95%E3%82%8C%E3%81%9F%202%20%E3%81%A4%E3%81%AE%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%82%82%E5%90%8C%E3%81%98%E3%81%93%E3%81%A8%E3%82%92%E8%A1%8C%E3%81%84%E3%80%81%E5%A4%96%E7%A9%8D%E3%81%AB%E3%82%88%E3%82%8A%E3%81%9D%E3%81%AE%E5%B9%B3%E9%9D%A2%E3%81%AE%E6%B3%95%E7%B7%9A%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%8C%E5%BE%97%E3%82%89%E3%82%8C%E3%81%BE%E3%81%99%E3%80%82%20%E5%95%8F%E9%A1%8C%E3%81%AF%E3%80%81%E4%B9%97%E7%AE%97%E3%81%95%E3%82%8C%E3%82%8B%202%20%E3%81%A4%E3%81%AE%E8%A1%8C%E5%88%97%20(v1%20%E3%81%A8%20v2)%20%E3%81%AE%E6%AC%A1%E5%85%83%E3%81%8C%E4%B8%80%E8%87%B4%E3%81%97%E3%81%AA%E3%81%84%E3%81%93%E3%81%A8%E3%81%AE%E3%82%88%E3%81%86%E3%81%A7%E3%81%99%E3%80%82nRows(v1)%20%E3%81%AF%20nCols(v2)%20%E3%81%A8%E7%AD%89%E3%81%97%E3%81%84%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%AE%E5%A4%96%E7%A9%8D%E3%81%AE%E7%B0%A1%E7%95%A5%E5%8C%96%E3%81%95%E3%82%8C%E3%81%9F%E5%BC%8F%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%81%93%E3%82%8C%E3%82%92%E6%89%8B%E5%8B%95%E3%81%A7%E5%AE%9F%E8%A3%85%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%99%E3%81%8C%E3%80%81%E8%A1%8C%E5%88%97%E3%81%AE%E4%B9%97%E7%AE%97%E3%82%92%E5%87%A6%E7%90%86%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E3%81%93%E3%82%8C%E3%82%92%E5%88%A5%E3%81%AE%E5%BD%A2%E5%BC%8F%E3%81%A7%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%82%92%E7%9F%A5%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B%E4%BA%BA%E3%81%AF%E3%81%84%E3%81%BE%E3%81%99%E3%81%8B%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-611821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-611821%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9%E3%81%8C%E5%8A%A3%E3%81%A3%E3%81%A6%E3%81%84%E3%81%A6%E3%82%82%E4%B8%8D%E6%80%9D%E8%AD%B0%E3%81%A7%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93...%E7%AC%A6%E5%8F%B7%E8%AA%BF%E6%95%B4%E3%82%92%E5%85%A5%E3%82%8C%E3%81%A6%E3%81%8F%E3%82%8C%E3%81%A6%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%80%82%20%E3%81%86%E3%81%A3%E3%81%8B%E3%82%8A%E3%80%8C%E3%82%B5%E3%82%A4%E3%83%B3%E3%83%81%E3%82%A7%E3%83%83%E3%82%AB%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%80%8D%E3%82%92%E7%9C%81%E7%95%A5%E3%81%97%E3%81%A6%E3%81%97%E3%81%BE%E3%81%84%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E7%A7%81%E3%81%AE%E6%84%8F%E8%A6%8B%E3%81%A7%E3%81%AF%E3%80%81%E3%81%93%E3%82%8C%E3%81%AF%E3%80%8C%E3%81%A7%E3%81%8D%E3%82%8B%E3%81%8B%E3%82%89%E3%81%A8%E3%81%84%E3%81%A3%E3%81%A6%E3%80%81%E3%81%9D%E3%81%86%E3%81%99%E3%81%B9%E3%81%8D%E3%81%A7%E3%81%82%E3%82%8B%E3%81%A8%E3%81%AF%E9%99%90%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%8D%E3%81%8C%E5%BD%93%E3%81%A6%E3%81%AF%E3%81%BE%E3%82%8B%E4%BE%8B%E3%81%AE%201%20%E3%81%A4%E3%81%A7%E3%81%99...%20%7B%E3%81%8B%E3%81%A3%E3%81%93%E3%81%84%E3%81%84%E3%80%81%E6%A5%BD%E3%81%97%E3%81%84%E3%80%81%E7%9F%AD%E3%81%84%7D%E3%81%AF%E3%80%81%7B%E7%90%86%E8%A7%A3%E3%81%A7%E3%81%8D%E3%82%8B%E3%80%81%E4%BF%9D%E5%AE%88%E3%81%97%E3%82%84%E3%81%99%E3%81%84%E3%80%81%E9%80%9F%E3%81%84%7D%E3%82%92%E4%B8%8A%E5%9B%9E%E3%82%8B%E3%81%93%E3%81%A8%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%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%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%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%E3%81%84%E3%81%84%E3%81%AD%EF%BC%81%20%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E5%BE%AE%E8%AA%BF%E6%95%B4%E3%81%8C%E5%BF%85%E8%A6%81%E3%81%A7%E3%81%99%E3%80%82%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%E4%B8%AD%E5%A4%AE%E3%81%AE%E8%A6%81%E7%B4%A0%E3%81%8C%E3%81%A9%E3%81%AE%E3%82%88%E3%81%86%E3%81%AB%E8%B2%A0%E3%81%A7%E3%81%82%E3%82%8B%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8B%E3%81%8B%E3%82%92%E7%A4%BA%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%E4%B8%8A%E8%A8%98%E3%81%A7%E3%81%AF%E3%80%81j%20%E3%81%AE%E7%AC%A6%E5%8F%B7%E3%81%8C%E4%BA%A4%E4%BA%92%E3%81%AB%20(1%E3%80%81-1%E3%80%811)%E3%80%81i%20%E3%81%8C%E5%A2%97%E5%8A%A0%E3%81%97%E3%81%BE%E3%81%99%20(1%E3%80%812%E3%80%813)%E3%80%82%20J(...)%20%E9%96%A2%E6%95%B0%E3%81%AB%E3%81%AF%E3%80%81%E5%90%84%E8%A6%81%E7%B4%A0%E3%81%AE%203%20%E7%95%AA%E7%9B%AE%E3%81%AE%E5%BC%95%E6%95%B0%E3%82%92%E8%A9%95%E4%BE%A1%E3%81%99%E3%82%8B%E6%9A%97%E9%BB%99%E7%9A%84%E3%81%AA%E3%83%AB%E3%83%BC%E3%83%97%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E3%81%8B%E3%82%89%E3%81%AE%E7%9B%B4%E6%8E%A5%E7%9A%84%E3%81%AB%E4%BF%AE%E6%AD%A3%E3%81%95%E3%82%8C%E3%81%9F%E5%BC%8F%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%E7%B4%84%203%20%E5%80%8D%E9%80%9F%E3%81%8F%E3%80%81%E7%B4%84%20N%20%E5%80%8D%E7%90%86%E8%A7%A3%E3%81%97%E3%82%84%E3%81%99%E3%81%8F%E3%81%AA%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E3%83%86%E3%82%B9%E3%83%88%E3%82%B3%E3%83%BC%E3%83%89%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%E3%82%82%E3%81%A3%E3%81%A8%E8%A6%8B%E3%82%8B...%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%E4%B8%8D%E6%80%9D%E8%AD%B0%E3%81%AA%E3%81%93%E3%81%A8%E3%81%AB%E3%80%8111%20%E4%BD%8D%E3%81%AB%E5%9B%9B%E6%8D%A8%E4%BA%94%E5%85%A5%E3%81%99%E3%82%8B%E3%81%A8%E7%B5%90%E6%9E%9C%E3%81%8C%E4%B8%80%E8%87%B4%E3%81%97%E3%81%AA%E3%81%84%E3%81%93%E3%81%A8%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%20%E3%81%8A%E3%81%9D%E3%82%89%E3%81%8F%E3%81%BB%E3%81%BC%E5%90%8C%E4%B8%80%E7%B7%9A%E4%B8%8A%E3%81%AE%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%A7%E3%81%99%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)%5BRemove(%20%5B%201%E3%80%812%E3%80%813%5D%E3%80%81i%2B%2B%20)%E3%80%810%5D%20)%20)%3B%20)%3B%20stop%20%3D%20HP%20%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.3%20%E7%A7%92%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%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%5B%201%5D%20*%20v2%5B3%5D%E3%80%81v1%5B1%5D%20*%20v2%5B2%5D%20-%20v1%5B2%5D%20*%20v2%5B1%5D%7D%20)%20%3B%20stop%20%3D%20HP%20%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%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%E3%83%A9%E3%83%B3%E3%83%80%E3%83%A0%E5%9D%87%E4%B8%80(%20-1%2C%201%20)%20)%3B%20v2%20%3D%20J(%203%2C%201%2C%20%E3%83%A9%E3%83%B3%E3%83%80%E3%83%A0%E5%9D%87%E4%B8%80(%20-1%2C%201%20)%20)%3B%20If(%20All(%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%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)%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%20)%20%3D%3D%200%2F%2F%20%2C%20%2F%2F%20Throw(%20Char(%20q%20)%20)%20)%3B%20)%3B%E4%B8%8D%E6%80%9D%E8%AD%B0%E3%81%AA%E3%81%93%E3%81%A8%E3%81%AB%E3%80%8111%20%E4%BD%8D%E3%81%AB%E5%9B%9B%E6%8D%A8%E4%BA%94%E5%85%A5%E3%81%99%E3%82%8B%E3%81%A8%E7%B5%90%E6%9E%9C%E3%81%8C%E4%B8%80%E8%87%B4%E3%81%97%E3%81%AA%E3%81%84%E3%81%93%E3%81%A8%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%20%E3%81%8A%E3%81%9D%E3%82%89%E3%81%8F%E3%81%BB%E3%81%BC%E5%90%8C%E4%B8%80%E7%B7%9A%E4%B8%8A%E3%81%AE%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%A7%E3%81%99%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%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-611656%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%81%95%E3%81%A6%E3%80%81%E5%BE%A9%E6%B4%BB%E3%81%97%E3%81%9F%E3%82%BE%E3%83%B3%E3%83%93%E3%81%8C%E7%A7%81%E3%82%92%E6%8D%95%E3%81%BE%E3%81%88%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%20%E3%81%93%E3%82%8C%E3%81%AF%E8%A1%8C%E5%88%97%E5%BC%8F%E3%82%92%E4%BB%8B%E3%81%97%E3%81%A6%E3%81%9D%E3%82%8C%E3%82%92%E8%A1%8C%E3%81%86%E6%96%B9%E6%B3%95%E3%81%A7%E3%81%99%E3%80%82%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F982%22%20target%3D%22_blank%22%3E%20%40Craige_Hales%3C%2FA%3E%E8%A8%80%E5%8F%8A%E3%81%95%E3%82%8C%E3%81%9F%E3%80%82%20%E7%9F%AD%E3%81%84%E3%81%A7%E3%81%99%E3%81%8C%E3%80%81%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93...%E3%81%9D%E3%82%8C%E3%81%BB%E3%81%A9%E5%8D%98%E7%B4%94%E3%81%A7%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%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%E3%81%A4%E3%81%BE%E3%82%8A%E3%80%81%E6%9C%80%E5%88%9D%E3%81%AB%E6%8F%90%E4%BE%9B%E3%81%95%E3%82%8C%E3%81%9F%E3%83%87%E3%83%BC%E3%82%BF%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%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%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-610312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%81%93%E3%81%AE%E3%82%BE%E3%83%B3%E3%83%93%20%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89%E3%82%92%E5%BE%A9%E6%B4%BB%E3%81%95%E3%81%9B%E3%81%A6%E7%94%B3%E3%81%97%E8%A8%B3%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%81%8C%E3%80%81%E3%81%93%E3%81%93%E3%81%AE%202%20%E7%95%AA%E7%9B%AE%E3%81%AE%E8%A6%81%E7%B4%A0%E3%81%AB%E7%AC%A6%E5%8F%B7%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%E3%81%9D%E3%81%86%E3%81%82%E3%82%8B%E3%81%B9%E3%81%8D%E3%81%A0%E3%81%A8%E4%BF%A1%E3%81%98%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%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%E7%B0%A1%E5%8D%98%E3%81%AB%E3%82%B3%E3%83%94%E3%83%BC%EF%BC%86%E3%83%9A%E3%83%BC%E3%82%B9%E3%83%88%E3%81%A7%E3%81%8D%E3%82%8B%E4%BB%96%E3%81%AE%E4%BA%BA%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AB%E3%80%81%E3%81%93%E3%82%8C%E3%82%92%E3%81%93%E3%81%93%E3%81%AB%E6%AE%8B%E3%81%97%E3%81%A6%E3%81%8A%E3%81%8D%E3%81%9F%E3%81%84%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%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%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236315%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Ecwillden%20%E3%81%AB%E6%84%9F%E8%AC%9D%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%E3%81%93%E3%82%8C%E3%81%AF%E5%9F%BA%E6%9C%AC%E7%9A%84%E3%81%AB%E7%A7%81%E3%81%8C%E5%AE%9F%E8%A3%85%E3%81%97%E3%81%9F%E3%82%82%E3%81%AE%E3%81%A7%E3%81%99%E3%80%82%20%E7%A7%81%E3%81%AF%203D%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%AE%E3%81%BF%E3%81%AB%E9%96%A2%E5%BF%83%E3%81%8C%E3%81%82%E3%82%8B%E3%81%AE%E3%81%A7%E3%80%81%E3%81%93%E3%82%8C%E3%81%AF%E6%A9%9F%E8%83%BD%E3%81%97%E3%81%BE%E3%81%99%E3%81%8C%E3%80%81%E3%81%93%E3%82%8C%E3%81%8C%E7%B5%84%E3%81%BF%E8%BE%BC%E3%81%BF%E9%96%A2%E6%95%B0%E3%81%A7%E3%81%AF%E3%81%AA%E3%81%84%E3%81%93%E3%81%A8%E3%81%AB%E9%A9%9A%E3%81%8D%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%20%E4%BB%96%E3%81%AB%E3%81%9D%E3%81%AE%E3%82%88%E3%81%86%E3%81%AA%E6%96%B9%E6%B3%95%E3%82%92%E7%9F%A5%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B%E4%BA%BA%E3%81%8C%E3%81%84%E3%82%8B%E3%81%8B%E3%81%A9%E3%81%86%E3%81%8B%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E3%80%81%E3%81%97%E3%81%B0%E3%82%89%E3%81%8F%E3%81%93%E3%82%8C%E3%82%92%E9%96%8B%E3%81%84%E3%81%9F%E3%81%BE%E3%81%BE%E3%81%AB%E3%81%97%E3%81%A6%E3%81%8A%E3%81%8D%E3%81%BE%E3%81%99%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%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236298%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%AA%B0%E3%81%8B%E3%81%8C%E3%81%93%E3%82%8C%E3%82%92%E8%A1%8C%E3%81%86%E8%B3%A2%E3%81%84%E6%96%B9%E6%B3%95%E3%82%92%E8%80%83%E3%81%88%E5%87%BA%E3%81%99%E3%81%93%E3%81%A8%E3%82%92%E9%A1%98%E3%81%A3%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%20det()%20%E9%96%A2%E6%95%B0%E3%81%AF%E5%AF%86%E6%8E%A5%E3%81%AB%E9%96%A2%E9%80%A3%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%81%8C%E3%80%81%E3%82%B9%E3%82%AB%E3%83%A9%E3%83%BC%E5%80%A4%E4%BB%A5%E4%B8%8A%E3%81%AE%E3%82%82%E3%81%AE%E3%82%92%E8%BF%94%E3%81%99%E3%81%9F%E3%82%81%E3%81%AB%20det(3x3%20%E8%A1%8C%E5%88%97)%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%81%8C%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%20det(2x2%20sub-matrix)%20%E3%82%92%203%20%E5%9B%9E%E4%BD%BF%E7%94%A8%E3%81%A7%E3%81%8D%E3%82%8B%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%E3%81%8C%E3%80%81%E5%8D%98%E7%B4%94%E6%98%8E%E5%BF%AB%E3%81%AA%E6%96%B9%E6%B3%95%E3%81%A0%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%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%3E%E3%82%AD%E3%82%B7%E3%82%B8%E3%83%BC%3C%2FA%3E%E3%82%A2%E3%83%97%E3%83%AD%E3%83%BC%E3%83%81%E3%81%AF%E3%82%88%E3%82%8A%E7%B0%A1%E5%8D%98%E3%81%A7%E3%80%81%E5%90%8C%E3%81%98%E3%81%8F%E3%82%89%E3%81%84%E9%AB%98%E9%80%9F%E3%81%A7%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E3D%20%E3%82%B7%E3%83%BC%E3%83%B3%E3%81%AE%E3%82%B5%E3%83%BC%E3%83%95%E3%82%A7%E3%82%B9%E6%B3%95%E7%B7%9A%E3%81%AB%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%E3%81%84%E3%81%8F%E3%81%A4%E3%81%8B%E3%81%AE%20JSL%20%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%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%3ERe%3A%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E5%A4%96%E7%A9%8D%E3%81%AE%E8%A8%88%E7%AE%97%E6%96%B9%E6%B3%95%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236294%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E3x1%20(%E3%81%BE%E3%81%9F%E3%81%AF%201x3)%20%E3%83%99%E3%82%AF%E3%83%88%E3%83%AB%E3%81%AE%E3%81%BF%E3%82%92%E6%89%B1%E3%81%86%E5%A0%B4%E5%90%88%E3%80%81%E8%A8%88%E7%AE%97%E5%8A%B9%E7%8E%87%E3%82%84%E5%84%AA%E9%9B%85%E3%81%95%E3%81%AF%E3%81%9D%E3%82%8C%E3%81%BB%E3%81%A9%E9%87%8D%E8%A6%81%E3%81%A7%E3%81%AF%E3%81%AA%E3%81%84%E3%81%A8%E6%80%9D%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%E3%81%93%E3%82%8C%E3%81%A7%E5%8D%81%E5%88%86%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%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}.