Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ruler501

Pages: 1 [2] 3 4 ... 184
16
Computer Programming / Re: Testing if a rational is in the cantor set
« on: February 05, 2014, 01:40:01 pm »
I do have the same denominator a lot(order of 2*3^12 to 2 * 3^13 times in the current run), but I can't cache all of them because that would be 2*3^15 different values(stored in 8 bytes each) which would be 219mb of data(actually this might be reasonable) I might try to find a way to just pass it in so it doesn't have to be stored.
I'll do that later today and speed test it to see if there is any significant benefit.

17
Computer Programming / Re: Testing if a rational is in the cantor set
« on: February 04, 2014, 03:32:29 pm »
That's the only problem I found. I'll post my whole program later
Edit: also my code will never give it more than 3^20 and unsigned long long shouldn't overflow till 3^40

EDIT2: Here's the whole program. It is counting all rationals with denominators(in simplest form) between 3^n and 3^(n+1) in the cantor set
Code: [Select]
#include <iostream>
#include <algorithm>
#include <thread>
#include <cmath>

#define THREADS 8

using namespace std;

bool testCantor(unsigned long long p, unsigned long long q){
   while(q % 3 == 0){
      q /= 3;
      if(p/q == 1) return p == q;
      p %= q;
   }
   unsigned long long p_start = p;
   do{
      unsigned long long p3 = p * 3;
      if(p3/q == 1) return false;
      p = p3 % q;
   } while(p != p_start);
   return true;
}

void genRational(unsigned long long minNum, unsigned long long maxNum, int jump, unsigned long long *result){
    for(unsigned long long q = minNum; q <= maxNum; q += jump)
        for(unsigned long long p = 1; p < q/3; p++)
            if(p % 3 != 0 && testCantor(p, q) && __gcd(p,q) == 1)
                for(unsigned long long i = p; i < q/3; i *= 3)
                        (*result) += 2 * (__gcd(i,q) == 1);
}

int main(int argc, char* argv[]){
    int n = argc;
    unsigned long long minNum = pow(3, n), *tempLongLong = nullptr, maxNum = pow(3, n+1), result = 0;
    vector<thread*> usedThreads;
    vector<unsigned long long*> results;
    thread* tempThread = nullptr;
    for(int i = 0; i < THREADS; i++){
        tempLongLong = new unsigned long long(0);
        results.push_back(tempLongLong);
        tempThread = new thread(genRational, minNum + i, maxNum, THREADS, tempLongLong);
        usedThreads.push_back(tempThread);
    }
    for(auto i = usedThreads.begin(); i != usedThreads.end(); i++) (*i)->join();
    for(auto i = results.begin(); i != results.end(); i++) result += **i;
    cout << n << " " << result << endl;
}

EDIT: Used an additional property for halving the search space(if a number x is in the cantor set then 1-x is also in the set). I haven't tested the code yet(using windows which stubbornly won't compile if I'm using threads)

EDIT2: Have it down to only checking 2/9 of the rationals(though depending on rounding may miss 1, but that should barely affect results)
also as a note to calcdude84se your else statements in the function didn't actually do anything(the if returned so execution stopped there if it was true), so I removed them. Not sure if that actually boosts performance though.

18
Computer Programming / Re: Testing if a rational is in the cantor set
« on: February 04, 2014, 02:35:58 pm »
It runs slightly faster than mine did and is much more accurate. One problem though your check for p/q==1 needs to return p==q not false because if it terminates with a 1 it is in the Cantor set (change the 1 to a 0 and add repeating 2 after it)

19
Computer Programming / Testing if a rational is in the cantor set
« on: February 03, 2014, 05:05:58 pm »
Is there a fast way to test for membership in the cantor set. My only idea is to test out to some threshold(25 digits or so) and if there are no ones(in ternary) before that to assume it is in the cantor set. This might work, but it is likely to include more rationals than it should(though q will always be under 3^20). Is there a better(preferably fast) way to do this? My code currently spends 97% of it's time in this function(though it is called ~2 million times) and any improvements will give me massive performance boosts.

This is my current code(THRESH is 70 which should be more precision than unsigned long long provides)

Code: [Select]
bool testCantor(unsigned long long p, unsigned long long q)
{
    unsigned long double rem = ((long double)p)/q, div = ((long double)1)/3;
    int test;
    unsigned long long mult = 3;
    for(int i=0; i<THRESH; i++)
    {
        test = rem * mult;
        if(test == 1)
        {
             if(rem > div) return false;
             else return true;
        }
        rem -= test*div;
        mult *= 3;
        div /= 3;
    }
    return true;
}

20
Other / Re: Wanting to get a desktop
« on: January 30, 2014, 11:32:50 am »
if it's an i5 or a xeon hyperthreading shouldn't really matter

21
Other / Re: Wanting to get a desktop
« on: January 30, 2014, 10:56:51 am »
Actually looking online it seems that they are pretty much the same(though you can't overclock the xeons it seems).

22
Other / Re: Wanting to get a desktop
« on: January 30, 2014, 02:41:41 am »
There are more benefits to the i5/i7 line than just the GPU. I'd think you could get an i5 for the same price.

The GPU looks good though.

23
I would be happy if we had another competition. I could put up an amazon gift card($25) for it.
I'd like a computer competition, but anything that helps the community is good.

24
Computer Usage and Setup Help / Re: Most worthwhile Upgrades
« on: December 31, 2013, 10:12:57 pm »
No room on my desk for it :P
Monitors and microwave(with printer on top). Take up all the space.

Edited first post to include all the upgrades added and other updated infromation

25
Computer Usage and Setup Help / Re: Most worthwhile Upgrades
« on: December 31, 2013, 05:47:10 pm »
BUMP
I was gone for a week but just got back and ordered the SSD and cooler. They should be here later this week. I still have ~400 I could spend if there are worthwhile upgrades for that price(if I get a second graphics card for crossfire I'll probably need a new PSU)

26
Miscellaneous / Re: Christmas 2013 - What did you get?
« on: December 25, 2013, 08:24:25 pm »
I got some money for computer upgrades, a memory foam pad for my dorm room bad, a t-shirt, klipsch image s4i(which actually work pretty well with my s4 just volume buttons don't work) earbuds, a nice new wallet, and a suitcase for when I go to England this summer.

27
Computer Usage and Setup Help / Most worthwhile Upgrades
« on: December 25, 2013, 08:19:45 pm »
I built this computer a little ways back

PCPartPicker part list / Price breakdown by merchant / Benchmarks

CPU:  Intel Core i7-4770K 3.5GHz Quad-Core Processor  ($279.99 @ Microcenter)
CPU Cooler:  NZXT Kraken X60 98.3 CFM Liquid CPU Cooler  ($125.99 @ Newegg)
Motherboard:  MSI Z87-G41 PC Mate ATX LGA1150 Motherboard  ($109.99 @ Microcenter)
Memory:  G.Skill Ares Series 16GB (2 x 8GB) DDR3-1866 Memory  ($135.00 @ Newegg)
Storage:  Samsung EVO 1TB 2.5" Solid State Disk  ($581.95 @ Newegg)
Storage:  Seagate Barracuda 1TB 3.5" 7200RPM Internal Hard Drive  ($59.99 @ NCIX US)
Video Card:  Sapphire Radeon HD 7970 3GB Video Card
Case:  Rosewill PATRIOT ATX Mid Tower Case  ($75.98 @ Newegg)
Power Supply:  Corsair CX 750W 80+ Bronze Certified Semi-Modular ATX Power Supply  ($95.98 @ Newegg)
Optical Drive:  LG GH24NS95 DVD/CD Writer  ($21.98 @ OutletPC)
Operating System:  Microsoft Windows 8 (OEM) (64-bit)  ($97.98 @ OutletPC)
Monitor:  Hannspree HE245DPB 60Hz 23.6" Monitor  ($129.99 @ TigerDirect)
Monitor:  Hannspree HE245DPB 60Hz 23.6" Monitor  ($129.99 @ TigerDirect)
Monitor:  Hannspree HE245DPB 60Hz 23.6" Monitor  ($129.99 @ TigerDirect)
Keyboard:  Rosewill RK-9000BR Wired Standard Keyboard  ($81.98 @ Newegg)
Other: 320gb 5400RPM laptop harddrive (Purchased)
Other: Microsoft Windows 7 Home Premium SP1 (OEM) (64-bit) (Purchased)
Total: $2029.41
(Prices include shipping, taxes, and discounts when available.)
(Generated by PCPartPicker 2014-01-01 11:48 EST-0500)

Now I've made some money from trading doge and christmas and am looking to upgrade it. I got a liquid cooler and an SSD, but I can get more(I have about $400 more). What else would most benefit my computer? I mainly use it for gaming and programming(run a few VM's sometimes). If there are no really great upgrades I'll probably just save the money.

I was  told that a sound card might be a nice addition and this looked like a good one http://pcpartpicker.com/part/creative-labs-sound-card-70sb151000000 I don't know much about them though. One thing I think it might be good to note is that I don't have the best speakers(using ones built into my monitors and a cheap($8) set right now) and my headphones are Logitech G930's which are wireless 7.1 and I believe they have a sound card built into the usb dongle they use. Would it be worth much to add a sound card without buying new headphones? I don't really want to have to buy new headphones right now so I probably won't do it if it doesn't help much(I compose music occasionally though)

What other upgrades might be worthwhile? If I go with the sound card I still have over $200

28
Miscellaneous / Re: Bitcoin - the currency of the internet.
« on: December 12, 2013, 03:14:27 pm »
It is a great coin. has random block reward and is valued at a wide range, but I usually get about $11 per 10k

29
Miscellaneous / Re: Bitcoin - the currency of the internet.
« on: December 12, 2013, 12:30:23 pm »
Doge coin is a good alt coin to try with. There is no exchange that carries it but you can trade it on there forum. I have made $58 and 0.02BTC in ~36 hours

30
Math and Science / Re: .9 repeating equals 1?
« on: December 10, 2013, 11:44:27 pm »
It approaches 1 as the length goes to infinity. For any value \delta more than 0 you can choose a natural number N so that the number .99999... with N digits or more will be within \delta of 1.

Pages: 1 [2] 3 4 ... 184