Jump to content

fredreload

Senior Members
  • Posts

    1123
  • Joined

  • Last visited

Everything posted by fredreload

  1. I'd like to know an actual result if someone decides to do an experiment on this
  2. Right I know, well alright, but what happens when you shine cyan, magenta, and yellow light together in this manner. The lights do not interfere and filter with each other right? What would the color be at the center? P.S. They could be ambient lights, but what would be the result of these three ambient lights combined?
  3. Looking for a pair of subtractive color glasses, what would the world looks like through it? P.S. The sky would look white I think, saves energy? Invisible ship? P.S. Black is a mixture of magenta, yellow, and cyan P.S. Magenta, yellow, and cyan makes black light?
  4. And here it is, the world's smallest LED
  5. OLEDS is that being possibly one of the smallest light source. That gives the ability to electrically control the screen at a pixel scale without the back light since it is a light source on its own. What I would compare it with is an array of smallest RGB LEDS. That and having it being completely transparent and wearable device does have its limitations. But that wouldn't stop us from overloading arrays of small LEDS and create display from it. Possibly for bigger devices or for some college project designs.
  6. My technology is a few years behind lol. Thanks I'll look into OLEDS
  7. You are right there is data loss for light, well but the sole purpose of liquid crystal is to adjust the intensity of the light. Voltage = intensity. So I mean for those cool flexible monitors maybe there is an alternative way to changing the intensity of the light? Some type of filter technique
  8. Now don't call me stupid here I've looked at how LCD monitor works. But in my head I am looking for a fiber optic display. Fiber optic transfer light, but it sounds a bit weird having to beam the light on each fiber precisely on the side of the screen to generate an output in comparison to running electricity and changing voltage for an LCD monitor. But hey, the theoretical result is this monitor can act as both a display and a touch screen like this display here without the camera and it lasts a long time. I'm looking into this because of the flexible display design here that peak my interest. Eventually I want to apply this technology to an AR glasses. Now graphene is introduced for flexible display here for its conductivity. So, I want to hear what you guys think about the monitor display and how graphene works with LCD because I still do not fully understand the design
  9. Through transdifferentiation yes, but you think DNA technology will make it in 50 years?
  10. Hmm, the actual run for a 43 byte file generated 58 byte of storage. This wouldn't work unless you can predict the nth value. Kind of a pain. The nth value sequence goes like this 1, 5, 21, 69, 469, 2135, 16921, 84593.
  11. First let me explain what my program is doing. To begin with, consider a data with 15, 1 bits and 15, 0 bits. It can be an image, a game, or any file. Let's assume this is my data 101010101010101010101010101010, I will have it arranged into 000000000000000111111111111111. Why do I re-arrage it? Because the data can now be remember as 15 0's 15 1's with the number 15 where I summed up the bits instead of typing 000000000000000 and 111111111111111. It is now stored as a sum of base 10 number. Now the important thing is the number n it takes to get from 101010101010101010101010101010 to 000000000000000111111111111111 which takes binary permutation. I chose this number because this is the worst case for 30 bits, 30 choose 15. If you have 30 1's or 30 0's it's simply 30 choose 30 which makes n=1 so that it only takes 1 number to get to the desired output. The number n can be found with the solution from Staphen I posted in this forum. The good thing is this number n will always be less than the actual number. Keep in mind n is a large number. Now that we've acquired the number n and the 15 0's and 15 1's, it's time to find the original data. But before we do this we can further shrink the number n. Let's assume n is one hundred which is 1100100 in binary, we find how far it is away from 0000111 and find the n again. The result is an array of zeros, ones, and the final number n. It's a really good algorithm, just doesn't work on large files for now. Anyway, have fun, and don't break your hard drive! using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Threading.Tasks; using System.Text; namespace HelloWorld { class Hello { public static byte[] bytes = System.IO.File.ReadAllBytes(@"C:\Data\star.jpg"); public static byte[] bytes_new; static void Main() { StringBuilder sb = new StringBuilder(); /* for (int k = 0; k < bytes.Length; k++) { sb.Append(Convert.ToString(bytes[k], 2)); } sb.Clear(); sb.Append("10101011"); */ BigInteger nb = new BigInteger(bytes.Concat(new byte[] { 0 }).ToArray()); bytes_new = nb.ToByteArray(); for (int i = 0; i < bytes_new.Length; i++) { sb.Append(Convert.ToString(bytes_new, 2).PadLeft(8, '0')); } Console.WriteLine(sb); Console.WriteLine(); int[] one = new int[50]; int[] zero = new int[50]; int[] position = new int[50]; for (int i = 0; i < 50; i++) { for (int j = 0; j < sb.Length; j++) { char c = sb[j]; if (c == '0') { zero++; } else { one++; } } //one = IteratedBitcount(number_compress); //zero = IteratedZerocount(number_compress); position = one + zero; BigInteger fac = Factorial(one); BigInteger n = FindN(sb, one, position, fac); sb = ToB(n,sb); //sb.Append(string.Join("",n.ToByteArray().Select(x => Convert.ToString(x, 2).PadLeft(8, '0')))); Console.WriteLine(sb); Console.WriteLine(); } //Console.WriteLine(number_compress); //Console.WriteLine(); /* for (int i = 0; i < 15-1; i++) { one = one - one[i+1]; position = position - position[i + 1]; } */ BigInteger number_decompress = 0; for (int i = 50 - 1; i >= 0; i--) { BigInteger fac = Factorial(one); number_decompress = FindNumber(sb, one, position, fac); sb = ToB(number_decompress, sb); //sb.Append(string.Join("",number_decompress.ToByteArray().Select(x => Convert.ToString(x, 2).PadLeft(8, '0')))); Console.WriteLine(sb); Console.WriteLine(); } //Console.WriteLine(number_decompress); Console.WriteLine(); byte[] final = new byte[sb.Length / 8]; for (int i = sb.Length/8-1; i >= 0; i--) { final = Convert.ToByte(sb.ToString(i*8, 8),2); } BigInteger b = new BigInteger(final); bytes_new = b.ToByteArray(); //byte[] buffer = Encoding.ASCII.GetBytes(sb.ToString()); File.WriteAllBytes(@"C:\Data\new_star.jpg", bytes_new); } static StringBuilder ToB(BigInteger n,StringBuilder sb) { sb.Length = 0; sb.Capacity = 0; sb.Clear(); int num = 0; while (BigInteger.Pow(2, num) <= n) { num++; } for (int k = num - 1; k >= 0; k--) { BigInteger counter = BigInteger.Pow(2, k); if (n >= counter) { sb.Append("1"); n = n - counter; } else { sb.Append("0"); } } return sb; } static string ToBinaryString(BigInteger bigint) { var bytes = bigint.ToByteArray(); var idx = bytes.Length - 1; // Create a StringBuilder having appropriate capacity. var base2 = new StringBuilder(bytes.Length * 8); // Convert first byte to binary. var binary = Convert.ToString(bytes[idx], 2); // Ensure leading zero exists if value is positive. if (binary[0] != '0' && bigint.Sign == 1) { base2.Append('0'); } // Append binary string to StringBuilder. base2.Append(binary); // Convert remaining bytes adding leading zeros. for (idx--; idx >= 0; idx--) { base2.Append(Convert.ToString(bytes[idx], 2).PadLeft(8, '0')); } return base2.ToString(); } static BigInteger FindNumber(StringBuilder sb, int one, int position, BigInteger fac) { BigInteger number = 0; BigInteger n = 0; int k = one; for (int l = 0; l < sb.Length; l++) { if (sb[l] == '1') { n = n + BigInteger.Pow(2, sb.Length-l-1); } } for (int j = position - 1; j >= 0; j--) { BigInteger mult = j; BigInteger num = 0; for (int i = 1; i < (int)k; i++) { mult *= (j - i); } num = (mult / fac); if (num <= n) { number = number + BigInteger.Pow(2, j); fac /= k; k--; n = n - num; } //Console.WriteLine(k); if (k == 0) break; } return number; } static BigInteger FindN(StringBuilder sb, int one, int position, BigInteger fac) { /* BigInteger findMSB = number; BigInteger test = number; BigInteger MSB = 1; while (findMSB > 0) { MSB <<= 1; findMSB >>= 1; } MSB >>= 1; */ BigInteger n = 0; int k = one; int pos = position; for (int i = 0; i < sb.Length; i++) { if (sb == '1') { int a = pos - 1; BigInteger mult = a; for (int j = 1; j < k; j++) { mult *= (BigInteger)(a - j); } n += (mult / fac); fac /= k; k--; } //Console.WriteLine(k); if (k == 0) break; 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++) { value *= index; } return value; } } } P.S. Tested on 1016 bits = =, if you want to run bigger files like 1MB, you will need to improve this algorithm or use a super computer P.S. By the way, I think you can shrink the keys
  12. I'll post a newer version of my code here later and see if you want to run it for me. I'll try a new multithreading methods, possibly this one
  13. I ran it for an entire night and the computer restarted at factorial 34729. It takes around 1 second to insert 2 records at this point. If database method does not work then maybe there is a way to improve computing speed? Or maybe multithreading.
  14. Well my problem is not inserting the number of rows, but each row has like 50000! number of text strings. 50000! numbers in 1 insert. So my problem is on how to insert a large chunk of data at once, but not inserting multiple rows
  15. If you revert back to earlier stages you'd be losing life experiences instead of gaining it. Neuronal signal might flow in reverse, not sure about that one
  16. Well I've been looking into digital immortality. Whether you can swap neurons to 3D neurons still remains a mystery.
  17. I'm doing insert from Visual Studio C#, I'm wondering if there is a script on MYSQL workbench that would generate the same thing and be faster. I'm thinking something like PL/SQL from Oracle, but whether it is faster I cannot say P.S. MYSQL has stored procedure P.S. Stored procedure can't handle large value multiplication and sql got too slow at around 50000!, what should I do?
  18. Division and multiplication is fast, I can get to 1 million factorial with no problem. The problem is inserting it as a text string into the database takes time and that is what I am looking into, faster way of insert large text strings.
  19. Hmm, I'm gonna work with the database first, I'm going to do a 1000000! then divide 1000000 and back until 1 to get the list. It should be fast P.S. You are free to test out the array method though, if you need the code just let me know, if you are in the mood to test it out that is P.S. Nevermind it's taking a long time writing the values into the database Need a fast way to insert large text to MYSQL, or something that can create value in DB like PLSQL
  20. No, but storing it in an array would lose it the next time you run the program. You're gonna keep it in a text? But calculating is the slowest. Well, what is your idea Strange?
  21. So I created a MYSQL database and attempted to store the factorial values, it took me an entire night to get to 10000. Suggestions needed, maybe multithreading with database insertion, is that possible? static private void ConnectAndQuery() { using (var connection = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost;Database=factorial;Uid=root;Pwd=freeloader;")) using (var command = connection.CreateCommand()) { connection.Open(); command.CommandText = "insert into table1(valf) values(@fac)"; command.Parameters.Add("@fac", "1"); BigInteger mult = 1; for (int i = 1; i < 1000000; i++) { Console.WriteLine(i); mult *= i; command.Parameters["@fac"].Value = mult; command.ExecuteNonQuery(); } command.CommandText = "select idf, valf from table1"; using (var reader = command.ExecuteReader()) while (reader.Read()) Console.WriteLine(reader.GetString(0) + ": " + reader.GetString(1)); } }
  22. I used a StringBuilder to append the bits, the compression rate is much better. But I still need to deal with the time = = Hmm, the thing is it is (a - i), and it could be something like mult = 15*14*13/5!, I'm interested in using a look up table, possibly a database? But I am a newbie at that, how do you think I should start? Other than the look up table, is there other possible methods? Btw I'm applying the recursive "a" computation I asked here. As an example of the multiplication BigInteger mult = 274341; for (int j = 1; j < 157594; j++) { mult *= (BigInteger)(274341 - j); } P.S. Right I see it, mult=a!/k!, looks like I need a look up table
  23. Let's see, I got a question first, I converted bytes to BigInteger like this BigInteger number_compress = new BigInteger(bytes.Concat(new byte[] { 0 }).ToArray()); Now the byte array is [378] byte array, as you know byte array is 8 bits each, so that's a total of 3024 bits. The thing is after conversion to number_compress, this BigInteger has 911 base 10 digits, so I'm not sure if BigInteger actually made the value bigger since I can't convert BigInteger to bits in c#. Below is the number. 10511498515079005786001923156952989929760765099887642049490645075407147670074787123453081119964496075798572683908765969937737368112628851278719151548358246532408860460103033076417881911156352613863717173123230737730516444716700786319847260734876596336573683014182274170198577808390323212579797450822781696155303651128091350419064337358263354652969443506081373456328170981909504950042936463577106765595222710454155651057937886003720893239530662179029448821080213785811445808269660735189910921681751787499664128734166678222596180132877088540155530232472178185615057339811168768357276447018187314658464330483545764600882883706505887000156889348127462631364561412835589414227905626001556124920721381180916353004195357239703395912173839712380569892467769276028873585749529029704900277393477308046170568306899216653561856937648186383356499772886802103617644079045242679876437789706198682378675257965584060895470702729
  24. This step is taking the most amount of my time. My best bet is a multiplication table stored in database, anyone else got any idea? The for loop here is taking too long, no for loop for (int i = 1; i < k; i++) { mult *= (a - (BigInteger)i); }
  25. Yes the output is identical to the input Strange . Gonna try optimizing this weekend, let me know if you can help lol Cool, I'll take it out, thanks!
×
×
  • 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.