Circshift function on very large array

조회 수: 9 (최근 30일)
Muhammad Waqas
Muhammad Waqas 2020년 7월 26일
답변: John D'Errico 2020년 7월 26일
My question is I am performing BWT transform whose first step is to perform circular shift on input text which can be from any txt file and save each shift to form NxN matrix, where N is length of input text from file. Now, if I input small text like name or some sentence of 30 character everything works very well. However,it sticks and gives error not enough memory if I input 1mb or more than 1 mb file. Please anyone here suggest me the solution?
  댓글 수: 3
Muhammad Waqas
Muhammad Waqas 2020년 7월 26일
Yes, size can carry depending upon size of input file
Muhammad Waqas
Muhammad Waqas 2020년 7월 26일
I input 1mb txt as a vector of length N and then try to create it's matrix of dimension NxN by applying circshift function

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

답변 (1개)

John D'Errico
John D'Errico 2020년 7월 26일
Yes, but you need to understand that just because your mind can conceive of an idea, does not mean your computer can solve the task.
The array that you want to create, for a vector with one million elements, for example, will create an array of size 1e6x1e6.
Assume that you are creating character arrays, so every element will require 2 bytes of storage. The result will be a total of 2 terabytes of memory required. Does your computer have more than 2 terabytes of contiguous RAM to store this array, and problem 2 or 3 times that, since you may need to make copies of it? I usually suggest 3 times the total memory is a good safe amount. These days, most computers seem to have between 4 and 64 gigabytes of memory. You would need roughly 1000 times as much memory to store this array.
So do you have terabyte sized RAM chips in your computer? Even with moderately inexpensive chips these days, terabyte RAM chips are still expensive. This is more memory than most people probably have in a disk drive.
The point is, your computer is not infinitely large in its capacity. If it tells you it does not have enough memory, then it says you are trying to do something impossible.
Computing is sometimes be viewed as an art. The art lies in learning to find better ways to solve a problem than just using brute force algorithms to solve a problem, that would be impossible to solve otherwise. We have no idea why you are wanting to do something impossibly large. But there are often better ways to crack a walnut than by dropping a Mack truck on top of it.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by