Jump to content

fredreload

Senior Members
  • Posts

    1123
  • Joined

  • Last visited

Everything posted by fredreload

  1. And here it is, the long waited algorithm thanks to Staphen that provided the algorithm in Crunchyroll. You are free to test it out on bigger files, currently it only runs for Blank.gif without going too slow. You are free to criticize only if you found a way to make this faster. Starting with iteratedbitcount. Thanks in advance! using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Threading.Tasks; namespace HelloWorld { class Hello { public static byte[] bytes = System.IO.File.ReadAllBytes(@"E:\data\Blank.gif"); public static byte[] bytes_new; static void Main() { BigInteger number_compress = new BigInteger(bytes); Console.WriteLine(number_compress); Console.WriteLine(); int[] one = new int[50]; int[] zero = new int[50]; int[] position = new int[50]; for (int i = 0; i < 50; i++) { //Console.WriteLine(i); one = IteratedBitcount(number_compress); zero = IteratedZerocount(number_compress); position = one + zero; BigInteger fac = Factorial(one); BigInteger n = FindN(number_compress, one, position); number_compress = n; } Console.WriteLine(number_compress); Console.WriteLine(); BigInteger number_decompress = 0; for (int i = 50-1; i >= 0; i--) { //Console.WriteLine(i); number_decompress = FindNumber(number_compress, one, position); number_compress = number_decompress; } Console.WriteLine(number_decompress); Console.WriteLine(); bytes_new = number_decompress.ToByteArray(); File.WriteAllBytes(@"E:\data\New_Blank.gif", bytes_new); } static BigInteger FindNumber(BigInteger n, int one, int position) { BigInteger number=0; int k = one; for (int j = position-1; j >=0 ; j--) { BigInteger mult = j; BigInteger num = 0; for (BigInteger i = 1; i < (BigInteger)k; i++) { mult *= (j - i); } num = (mult / Factorial(k)); if (num <= n) { number = number + BigInteger.Pow(2, j); k--; n = n - num; } if (k == 0) break; } return number; } static BigInteger FindN(BigInteger number, int one, int position) { BigInteger findMSB = number; BigInteger test = number; var numBits = (int)Math.Ceiling(BigInteger.Log(2)); BigInteger MSB=1; while (findMSB > 0) { MSB <<= 1; findMSB >>= 1; } MSB >>= 1; BigInteger n = 0; int k = one; int pos = position; while (MSB != 0) { if ((test & MSB) > 0) { int a = pos-1; BigInteger mult = a; for (BigInteger i = 1; i < (BigInteger)k; i++) { mult *= (a - i); } n += (mult/Factorial(k)); k--; } MSB >>= 1; pos--; } return n; } static int IteratedBitcount(BigInteger n) { BigInteger test = n; int count = 0; while (test != 0) { if ((test & 1) == 1) { count++; } test >>= 1; } return count; } static int IteratedZerocount(BigInteger n) { BigInteger test = n; int count = 0; while (test != 0) { if ((test & 1)==0) { count++; } test >>= 1; } return count; } static BigInteger Factorial(int arg) { BigInteger value = 1; for (int index = 2; index <= arg; index++) { //Console.WriteLine(index); value *= index; } return value; } } }
  2. Right I saw Stirling's formula but it is only an approximation, it is fast though. Well the idea is I want to be able to compute the highest complexity, for me it would be 1GB, or 8000000000 bits. The complexity of doing a permutation on 1GB would be to choose 4000000000 bits from it for the worst case scenario. What I eventually want to get out of this is a compression formula as I have posted in the Mathmatics section. Now I was able to generate the one million bit factorial in around 30 min. I'd imagine 1000 times of that to be about 30000 minutes. So to be realistic I'd test it on 8000000 choose 4000000 which is 1MB in this case. P.S. My compression algorithm goes like this: 1. For a 1MB file get the base permutation case on n=1 or for example 000000000000001111111111111111, store this value as 14 0's 16 1's 2. Compute the nth permutation for this sequence, which could be for example 110101010101010101010100111100, as long as it got 14 0's and 16 1's. 3. That is my data, for a 1MB file it is most likely an image. 4. Now my question is, I want to know where 110101010101010101010100111100 this sequence comes in as the nth permutation, we know the sequence for n=1, so I want to know which n=? is this for this sequence.
  3. Right as I've mentioned I want 0011 to be 1, so having all the one bits on the right as 1, then slowly move to the left. It really doesn't matter as long as I can track the sequence in an orderly fashion. So I want to be able to derive a sequence using the nth value. For instance I want n=5 to get me 1010 in this case P.S. We know how we can get any binary order using 2 to the power, for instance if I have n=15 I would get 15-2^3-2^2-2^1-2^0 and get 1111
  4. This is the last missing piece I need to complete my compression algorithm, new one. Let's say I have 4 bits with 2 bits set as 1, 0011. The total number of permutations for this number is 0011, 0101, 0110, 1001, 1010, 1100, 6 cases. This can be computed using the calculation. 4! / ((2!)(4-2)!) = 6 Now I want to be able to find the nth sequence, for instance 1st number is 0011, second number is 0101. So if I say n=5, I want to be able to get the 5th permutation sequence 1010 from the initial 0011. How do I do this?
  5. How do you store Factorial(1000000) in the database? I mean sure it is probably 5 million digits versus time but is the space worth it?
  6. I computed the dang thing Factorial(1000000) with BigInteger in like 5 minutes, but it's been 30 minutes and it hasn't printed the thing on console, why is that? By the way I am using this algorithm for compression, again, if someone is interested let me know
  7. This is really cool, although I have no idea what it is doing http://stackoverflow.com/questions/18911262/parallel-calculation-of-biginteger-factorial P.S. Hmm I decided to use BigInteger library for this, it is more efficient How long does it take?
  8. Cool, can you show me how to do that? I'm curious about it
  9. As the title implies, I need a way to compute a huge number of permutation fast, you can test it in this calculator. The order and repetition doesn't matter so choose no for both. Now the thing is since the number is so big, it would be store inside an array of number. And I've done that much, but to computer the number requires 800000000 iteration, and it takes a long time. I saw that Python has a script call npr that can computer it really fast. I want to know if there is a way to do it for c#. In other words, I want to compute 8000000000! / ((4000000000!)(8000000000-4000000000)!) Let me know if there is any lead in this one, I would like to know if there is a way besides 8000000000*7999999999*7999999998, etc. Any help is appreciated P.S. 5n 3r is 10 for the calculator, just so we have the same picture
  10. Hmm, as much as I would like to achieve biological immortality. Well there are still quite a lot of genes we aren't sure what it's doing. When this gene expression is turned on or off. And to observe these things we need a good resolution microscope so we can examine them in vitro. P.S. I'd wish it comes sooner too, but it just seems there are some limitations
  11. I take it back, there is an eternity, else I've just doomed us all @@ P.S. Going to sleep, good night all P.S. But it's not possible to seal someone for eternity
  12. Right it's a comedy. You don't really need to worry about next life. If you want to live longer then try to pursue immortality. There is no such thing as eternity P.S. Even if someone seals me for eternity, I will be out at eternity+1
  13. You can watch The Hitchhiker's Guide to the Galaxy, in my opinion they are somewhat similar
  14. Sure hope to meet you again Strange
  15. I'm taking in time as a factor, but it is also possible that you could exist in a different time, different body. Since consciousness does not exist at one time, so I can exist at different times , not sure if my body will stay the same
  16. Wikipedia says microRNA is capable of activating genes, but the video I posted only mentioned gene silencing so. The point is, if it can activate genes, that means it is capable of converting cell into stem cell like the transcription factors. There is an article says that they found microRNA in the regenerated lizard limb when it is forming a blastema, or lizard stem cells. So if microRNA is as powerful as it is, we could use it to create a transdifferentiation on our cells to reverse aging. What transdifferentiation does is it differentiate a cell to another type without going through the stem cell stage, I don't know about the details but apparently the immortal jellyfish has it thanks to Edward's post. What the IPSC stem cell is, the one that is obtained through transcription factors for as old as 82 years old cell, is showing no DNA damage, no mitochondria damage, or any signs of aging. Thing is the 82 years old skin cell has to division a few times before it becomes an IPSC stem cell. Trandifferentiate is capable of differentiating without having to divide cells. So now the point isn't trying to modify the cell's DNA, but trying to have the cell differentiate to an earlier stage. Which I speculate can be done with the correct microRNA. P.S. My original plan of use with microRNA, body cells-> revert to stem cells -> differentiate back to younger specialized cells P.S. Now body cells-> transdifferentiate to yonger cells
  17. There is a movie name Event Horizon, don't watch it if you are not into sci-fi horror
  18. Right thanks, this is a joke by the way
  19. Alright, some guy decides to kick the guy/girl away before he enters = =
  20. What is it? Does it exist?
  21. And I'll try to get a second immortal guy/girl in with me
  22. I wrote this code that take a long time to execute with great compression result. For a 1GB file you need to run something like n^2, n represents every bit there is, so you need to run 8000000000*8000000000, to get the 1GB file, but rather than storing it as bits you get a single number 8000000000. But since it takes a long time to execute, it gets a bit pointless, or so I feel. Imagine a single number 8000000000 being the 1GB game you want to play, all you do is take this code and decompress is back home Well ya, only if I get stuck in the nth dimension
  23. Well Strange, immortality means you don't die = =, you can starve yourself, stab in the heart but you live. After that plan for retirement, sorry to the two upstairs
  24. Strange, you see consciousness and unconsciousness is binary. Let's say I pass away like at 80, will my consciousness be rebuilt afterward, will someone has the technology to rebuild consciousness? If not, after the universe ends and another big bang where the universe gets created again, time resets, everything reset, eventually my consciousness will get created again at the same time in the same year, no matter how long it may take, lets say 10 billion years on the off state. But do I have consciousness when I am in the off state? No, I wake up as a new born the next second right after I passed away, to me this 10 billion years has no memory. So rather we are stuck on the off state, we are stuck repeating life again and again and again. How many times do you think we are repeating our life?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.