필터 지우기
필터 지우기

How can i create array of 1:2^1000 column size?

조회 수: 7 (최근 30일)
tushar bhonsle
tushar bhonsle 2019년 1월 13일
댓글: Steven Lord 2019년 1월 13일
I want to create an array of one column, which is long enough to 1:2^1000? Like a = [1:2^1000];

답변 (2개)

John D'Errico
John D'Errico 2019년 1월 13일
편집: John D'Errico 2019년 1월 13일
Let us be serious. How much memory would you need to store that array? How big is 2^1000? Don't forget to multiply the result by 8 to get the number of bytes, since these are double precison numbers stored. So we actually have 2^1003 bytes of memory. So how much memory will you need, in bytes?
vpi2english(vpi(2)^1003)
ans =
'eighty five novemnonagintillion, seven hundred twenty octononagintillion, six hundred eighty eight septennonagintillion, five hundred seventy four sexnonagintillion, nine hundred one quinnonagintillion, three hundred eighty five quattuornonagintillion, six hundred seventy five trenonagintillion, eight hundred seventy four duononagintillion, three unnonagintillion, nine hundred twenty four nonagintillion, eight hundred novemoctogintillion, one hundred forty four octooctogintillion, eight hundred forty four septoctogintillion, nine hundred twelve sexoctogintillion, three hundred eighty four quinoctogintillion, nine hundred thirty six quattuoroctogintillion, four hundred forty two treoctogintillion, six hundred eighty eight duooctogintillion, five hundred ninety five unoctogintillion, five hundred octogintillion, thirty one novemseptuagintillion, sixty nine octoseptuagintillion, six hundred twenty eight septenseptuagintillion, eighty four sexseptuagintillion, eighty nine quinseptuagintillion, nine hundred ninety four quattuorseptuagintillion, eight hundred eighty nine treseptuagintillion, seven hundred ninety nine duoseptuagintillion, four hundred fifty five unseptuagintillion, eight hundred seventy septuagintillion, three hundred five novemsexagintillion, two hundred fifty five octosexagintillion, six hundred sixty eight septensexagintillion, six hundred fifty sexsexagintillion, two hundred seven quinsexagintillion, five hundred seventy three quattuorsexagintillion, eight hundred thirty three tresexagintillion, four hundred four duosexagintillion, two hundred fifty one unsexagintillion, seven hundred forty six sexagintillion, fourteen novemquinquagintillion, nine hundred seventy one octoquinquagintillion, six hundred twenty two septenquinquagintillion, eight hundred fifty five sexquinquagintillion, three hundred eighty five quinquinquagintillion, one hundred twenty three quattuorquinquagintillion, four hundred eighty seven trequinquagintillion, eight hundred seventy six duoquinquagintillion, six hundred twenty unquinquagintillion, five hundred ninety seven quinquagintillion, five hundred eighty eight novemquadragintillion, five hundred ninety eight octoquadragintillion, four hundred thirty one septenquadragintillion, four hundred seventy six sexquadragintillion, five hundred forty two quinquadragintillion, one hundred ninety eight quattuorquadragintillion, five hundred ninety three trequadragintillion, eight hundred forty seven duoquadragintillion, eight hundred eighty three unquadragintillion, three hundred sixty eight quadragintillion, five hundred ninety six novemtrigintillion, eight hundred forty octotrigintillion, four hundred ninety eight septentrigintillion, nine hundred sixty nine sextrigintillion, one hundred thirty five quintrigintillion, twenty three quattuortrigintillion, six hundred thirty three tretrigintillion, four hundred fifty seven duotrigintillion, two hundred twenty four untrigintillion, three hundred seventy one trigintillion, seven hundred ninety nine novemvigintillion, eight hundred sixty eight octovigintillion, six hundred fifty five septenvigintillion, five hundred thirty sexvigintillion, one hundred thirty nine quinvigintillion, one hundred ninety quattuorvigintillion, one hundred forty trevigintillion, four hundred seventy three duovigintillion, three hundred twenty four unvigintillion, three hundred fifty one vigintillion, five hundred sixty eight novemdecillion, six hundred sixteen octodecillion, five hundred three septendecillion, three hundred sixteen sexdecillion, five hundred sixty nine quindecillion, five hundred seventy one quattuordecillion, eight hundred twenty one tredecillion, four hundred ninety two duodecillion, three hundred thirty seven undecillion, three hundred forty one decillion, two hundred eighty three nonillion, four hundred thirty eight octillion, six hundred fifty three septillion, two hundred twenty sextillion, nine hundred ninety five quintillion, ninety four quadrillion, six hundred ninety seven trillion, six hundred forty five billion, three hundred forty four million, five hundred fifty five thousand, eight '
Sigh. Do you have any idea how big of a number that is?
Do all of the computers on this planet have sufficient memory? No. Suppose you have the magical ability to turn every atom in the entire planet into a 1 gigabyte memory chip... Lets see, I found a quick approximation that suggests there are on the order of 1e50 atoms in this planet earth.
2^1003/(1e50*2^30)
ans =
7.9834e+242
So if you could turn the entire planet into atom sized gigabyte memory chips, it would require on the order of 8e242 planetary computer memories.
Not gonna happen. Ever. People seem to think their computers are big, fast, powerful. It can do anything, if you just know the magic trick to write the code. In fact, your computer is not that big or powerful. It is trivially easy to try to do something that is wildly beyond the capability of your computer, or the most powerful super computer you will ever find.
So, what can you do? A lot of mathematics is about avoiding the use of brute force to any extent possible. Use finesse instead. Of course, I have no idea what your problem is that you are trying to solve, since you have told us nothing, only what it is you think you need to do. But you cannot solve your problem as you wish. So spend some time in rethinking your problem. Learn if there are better algorithmic choices available to you. See if there are approximations available or perhaps some sort of greedy algorithms. And sometimes, mathematics is about skill in reducing the problem, understanding what can be eliminated in what you want to solve. But you simply cannot solve this problem using pure brute force.
  댓글 수: 1
Steven Lord
Steven Lord 2019년 1월 13일
I prefer the number of atoms example. According to WIkipedia an estimate for the upper bound on the number of atoms in the observable universe is 1e80. If you could store one double precision value in each one of those atoms, do you have enough?
numAtoms = 1e80;
numElements = 2^1000;
numAtoms > numElements % false!
How many universes would you need?
numUniverses = numElements / numAtoms
I second John's recommendation to find an alternate solution.

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


madhan ravi
madhan ravi 2019년 1월 13일
편집: madhan ravi 2019년 1월 13일
It seems to be more than the limit
a=1:2^1000;
A=a.' % to force an array into a column vector
%or
A=a(:)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by