sumsqint

버전 1.1.0.0 (4.32 KB) 작성자: Ben Petschel
Finds all distinct ways of writing a number as the sum of squares, i.e. solve x^2+y^2=n for 0<=x<=y.
다운로드 수: 1.7K
업데이트 날짜: 2009/8/17

라이선스 보기

Example:

sumsqint(1) % returns [0,1]
sumsqint(65) % returns [1,8;4,7]

sumsqint can work with large numbers if they are factored, e.g. solve x^2+y^2=(25e6)^2:
sumsqint(repmat(factor(25e6),1,2)) % returns 9x2 array

sumsqint works with variable precision integers if you have John D'Errico's Variable Precision Integer toolbox (20 July 2009 update) - see links below.

sumsqint(vpi(5)^100) % returns 51x2 vpi array
sumsqint(vpi(65)^100) % returns 5101x2 vpi array

The algorithm uses Gaussian integer factorization. See the help for more details.

인용 양식

Ben Petschel (2024). sumsqint (https://www.mathworks.com/matlabcentral/fileexchange/24798-sumsqint), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2009a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

added support for factored inputs; fixed a bug in the handling of vpi numbers with prime factors larger than 100; added option to remember newly found gaussian prime factors.

1.0.0.0