필터 지우기
필터 지우기

What is the meaning of 'internal sorting rules' in 'sort' in Symbolic Math Toolbox?

조회 수: 1 (최근 30일)
A = [factorial(sym(1001)), exp(sym(1)) + factorial(sym(1000))]
[r,s] = sort(A)
Obviously, A(1) > A(2). However, the output is
r =
[factorial(1001), exp(1) + factorial(1000)]
s =
1 2
which is quite confusing.
I notice in sort, it is mentioned that
  • If X contains symbolic irrational numbers, expressions, and functions, comparing and sorting the elements can be computationally complex. Therefore, sort uses internal sorting rules to optimize its performance.
What is the meaning of 'internal sorting rules' ?
Thank you very much!

답변 (1개)

David Hill
David Hill 2022년 5월 6일
A = [factorial(sym(1001)), exp(sym(1)) + factorial(sym(1000))]
[~,s] = sort(vpa(A));%vpa the symbolic before sorting.
A=A(s);%sorted symbolic
  댓글 수: 1
Songbai Jin
Songbai Jin 2022년 5월 6일
Thank you for your answer!
But my original idea is to prevent a 'vpa' method.
Is it possible to sort sym variables directly?
Thank you for your answering anyway!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by