Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
V

VeganFanatic

@VeganFanatic
About
Posts
40
Topics
12
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\
    V VeganFanatic

    I added another layer of hKey lpData is char* applist is CString I got it figured out with a lot more code needed

    http://www.contract-developer.tk

    ATL / WTL / STL windows-admin help question

  • Avoiding MFC CString
    V VeganFanatic

    I use CString all the time but not the ATL::Cstring It seems to be handy with MessageBox and other system calls so I use it all the time What is the issue with CString that is bothering you?

    http://www.contract-developer.tk

    ATL / WTL / STL c++ help question

  • SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\
    V VeganFanatic

    So I am digging around deep in the registry So far so good, but I need to access specifics for each subkey

    	for (i=0; i<cSubKeys; i++)  { 
    		cbName = MAX\_KEY\_LENGTH;
    		retCode = RegEnumKeyEx(hKey, i,	achKey, &cbName, 0, 0, 0, &ftLastWriteTime); 
    		if (retCode == ERROR\_SUCCESS) {
    			RegQueryValueEx(hKey,L"DisplayName",NULL,NULL,(LPBYTE) lpData, &buffersize);
    			applist.push\_back(lpData);
    		}
    	}
    

    Anyway all I get are a bunch of "-" so am I getting the right type etc?

    http://www.contract-developer.tk

    ATL / WTL / STL windows-admin help question

  • backgroud worker thread crashes but fine when foreground
    V VeganFanatic

    Putting that module into a thread was to make the program able to quit at any time. This was to make sure the message handler is able to get messages.

    http://www.contract-developer.tk

    ATL / WTL / STL c++ question

  • backgroud worker thread crashes but fine when foreground
    V VeganFanatic

    I am going to use MessageBox all over the module and see how far it gets. One question, do I need to use the exitthread anywhere?

    http://www.contract-developer.tk

    ATL / WTL / STL c++ question

  • backgroud worker thread crashes but fine when foreground
    V VeganFanatic

    typedef std::basic_string<wchar_t> tstring; tstring output; The output will eventually be placed on the clipboard as a text

    http://www.contract-developer.tk

    ATL / WTL / STL c++ question

  • backgroud worker thread crashes but fine when foreground
    V VeganFanatic

    void showtime(void *dummy) {
    computing = true;
    output.clear();
    // Display the copyright
    output = _TEXT("Fibonacci 3.0.0 for Windows");
    output += ToString("/n/l/n/l");
    // f << name << ": " << time << " seconds" << std::endl << std::endl;
    output += _TEXT("(c) 2010-1 583727 BC Ltd, All Rights Reserved.");
    // f << name << ": " << time << " seconds" << std::endl << std::endl;
    output += _TEXT("/n/l");
    output += _TEXT("Free for peronsal use only");
    output += _TEXT("/n/l/n/l");
    output += _TEXT("Commercial and government use requires a license");
    output += _TEXT("/n/l/n/l");
    output += _TEXT("To acheieve consistant results, run this program in the clean boot mode");
    output += _TEXT("/n/l");
    output += _TEXT("Click on start, in the seach box enter 'msconfig' and choose the startup tab, disable everyting and reboot");
    output += _TEXT("/n/l/n/l");
    output += _TEXT("RAM Performance ");
    output += ToString(benchmark(fib2));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Scalar Performance ");
    output += ToString(benchmark(fib3));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("CPU Large Multiplication Performance ");
    output += ToString(benchmark(fib4));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    v.resize(0); t.resize(0); // free up some RAM
    output += _TEXT("Recursive Factorial Performance ");
    output += ToString(benchmark(RunFact));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Bubble Sort Performance ");
    output += ToString(benchmark(RunBubbleSort));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Insertion Sort Performance ");
    output += ToString(benchmark(RunInsertionSort));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Shell Sort Performance ");
    output += ToString(benchmark(RunShellSort));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Quick Sort Performance ");
    output += ToString(benchmark(RunQuickSort));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Merge Sort Performance ");
    output += ToString(benchmark(RunMergeSort));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Heap Sort Performance ");
    output += ToString(benchmark(RunHeapSort));
    output += _TEXT(" seconds");
    output += _TEXT("/n/l");
    output += _TEXT("Parallel Bitwise Sieve

    ATL / WTL / STL c++ question

  • backgroud worker thread crashes but fine when foreground
    V VeganFanatic

    I have this benchmark program that started off as a console program and I am now well into making work with a window instead. It's all Win32 for the most part with a smattering of C++ STL for some containers. I launch the background via a keyboard command ctrl-r

    			case (0x52): // R key
    				if(GetKeyState(VK\_LCONTROL) || GetKeyState(VK\_RCONTROL)) {
    					// crtl-r
    					// showtime(); //?
    					\_beginthread(showtime, NULL, NULL);
    				}
    				break;
    

    So what am I doing wrong, the background thread runs for while but crashes, used to work fine.

    http://www.contract-developer.tk

    ATL / WTL / STL c++ question

  • Linear Algebra with C++
    V VeganFanatic

    I have been working on a project for the last year and I have make much progress but much remains. First I will provide headers of what I have done so far.

    template <class T> class vector; // vector space
    template <class T> class matrix; // derived from vector
    template <typename T> T norm(vector<T> v);
    template <typename T> T norm(matrix<T> m);
    template <typename T> void transpose(matrix<T> &m);
    template <typename T> void conjugate_transpose(matrix<T> &m);
    template <typename T> bool hermetian(matrix<T> &a, matrix<T> &b);
    template <typename T> matrix<T> tensor_product(vector<T> row, vector<T> col);
    template <typename T> matrix<T> minor(matrix<T> &source, int row, int col);
    template <typename T> bool diagonal_dominant(matrix<T> a);
    template <typename T> matrix<T> gauss_elimination(matrix<T> &m);
    template <typename T> matrix<T> gauss_jordan(matrix<T> &m);
    template <typename T> void gauss_siedel(matrix<T> a, vector<T> b, vector<T> x, double tolerance);

    Now I can use vector and use it with math equations fine. Same for the matrix template. So given my work to make these helpful templates, I am now out of my math book big time and into the realm of advanced linear algebra. This is my Gauss elimination, and I was looking to leverage it to do LU decomposition etc to solve Ax = b more expediently.

    template <typename T> matrix<T> gauss_elimination(matrix<T> &mat) {
    int i = 0; int j = 0; int maxi;
    matrix<T> a = mat;
    int m = (int)a.size();
    int n = (int)a[0].size();
    while ((i < m) && (j < n)) {
    maxi = i;
    // sweep down the column to find the pivot element
    for (int k = i + 1; k < m; k++) // partial pivoting
    if (std::abs(a[k][j]) > std::abs(a[maxi][j])) maxi = k;
    // eliminate
    if (a[maxi][j] != 0) {
    swap(a[i], a[maxi]); // row op 1, swap
    a[i] = a[i] / a[i][j]; // row op 2, scale the pivot to 1
    for (int u = i + 1; u < m; u++)
    a[u] = a[u] - (a[i] * a[u][j]); // row op 3, zero out the column below
    i++;
    }
    j++;
    }
    return a;
    }

    Suggestions?

    http://www.contract-developer.tk

    ATL / WTL / STL c++ wpf graphics question learning

  • I cannot install sp1 package for the visual studio 2005 [modified][solved]
    V VeganFanatic

    Each client will need the appropriate run-time packages for the version of Visual Studio you are using. I have a bunch of the C++ ones in my forum for my Fibonacci project. This way users can download them as needed.

    http://www.contract-developer.tk

    ATL / WTL / STL c++ help csharp visual-studio question

  • Tranlating old code to the STL style
    V VeganFanatic

    Then I guess I need to change the function a tad, so that its a drop in comparable to std::sort. I changed the code while (pos < last) { from <= That has it working now, thanks for spotting that. Now I think I will post the code on Wilipedia as the algorithm is not super clear.

    http://www.contract-developer.tk

    ATL / WTL / STL c++ graphics algorithms

  • Tranlating old code to the STL style
    V VeganFanatic

    here is the call routine

    void RunGnomeSort(void) {
    size_t size = 10000;
    std::vector<int> data;
    data.resize(size);
    for (int i = 0; i < size; i++)
    data[i] = (int)rand();
    sort::gnome(data.begin(),data.end());
    //for (int i = 0; i < size; i++)
    //std::cerr << data[i] << std::endl;
    data.resize(0);
    }

    http://www.contract-developer.tk

    ATL / WTL / STL c++ graphics algorithms

  • Tranlating old code to the STL style
    V VeganFanatic

    After a few moments looking over the book I figured out that I need to watch the pointers close when using the STL method of iterators. This is not well covered in any of the books I have. No big deal, that is what forums are for. Here is what I ended up with that does work properly.

    template <typename iterator> void bubble(iterator first, iterator last) { // O(n^2)
    iterator i, j;
    for (i = first; i != last; ++i)
    for (j = first; j < i; ++j)
    if (*i < *j)
    std::iter_swap(i, j); // or std::swap(*i, *j);
    }

    Now I have this other sort that is annoying me.

    template <class iterator> void gnome(iterator first, iterator last){ // O(n^2)
    iterator pos = first;
    iterator temp;
    while (pos <= last) {
    if ((pos == first) || (*pos >= *(pos-1)))
    ++pos;
    else {
    //{int tmp = ar[i]; ar[i] = ar[i-1]; ar[--i] = tmp;}
    std::iter_swap(pos, pos-1);
    --pos;
    }
    }
    }

    This one does not work, not sure what the problem is.

    http://www.contract-developer.tk

    ATL / WTL / STL c++ graphics algorithms

  • Tranlating old code to the STL style
    V VeganFanatic

    OK I found a sort algorithm on Wikipedia, that is done like the std::sort so I figured why not convert the who lot that I have to STL. Blah. First the new sort

    template<class ForwardIterator> void comb(ForwardIterator first, ForwardIterator last){
    static const double shrink_factor = 1.247330950103979;
    typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
    difference_type gap = std::distance(first, last);
    bool swaps = true;
    while ( (gap > 1) || (swaps == true) ){
    if (gap > 1)
    gap = static_cast<difference_type>(gap/shrink_factor);
    swaps = false;
    ForwardIterator itLeft(first);
    ForwardIterator itRight(first); std::advance(itRight, gap);
    for ( ; itRight!=last; ++itLeft, ++itRight ){
    if ( (*itRight) < (*itLeft) ){
    std::iter_swap(itLeft, itRight);
    swaps = true;
    }
    }
    }
    }

    So now the old bubble sort

    template <typename T> void bubble(std::vector<T> &a) { // O(n^2)
    size_t size = a.size() - 1;
    for (int pass = 0; pass < size; pass++) {
    for (int n = 0; n < size; n++) {
    if (a[n] > a[n+1])
    std::swap(a[n], a[n+1]);
    }
    }
    }

    and this is as far as I have gone so far

    template<class ForwardIterator> void bubble(ForwardIterator first, ForwardIterator last){
    typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
    difference_type size = std::distance(first, last);
    }

    http://www.contract-developer.tk

    ATL / WTL / STL c++ graphics algorithms

  • Read CPU temp
    V VeganFanatic

    Looks like a glaring omission, as I have searched MSDN and found nothing, Google, no good and on Soureforge the stuff is specific to certain boards only. I guess I will have to ask users to watch the temps manually when using my benchmarks.

    http://www.contract-developer.tk

    C / C++ / MFC css hardware json question

  • Read CPU temp
    V VeganFanatic

    If needed I guess another template/class can act as an API. When in doubt, drop down to assembler. Then the whole machine is accessible.

    http://www.contract-developer.tk

    C / C++ / MFC css hardware json question

  • Read CPU temp
    V VeganFanatic

    I was looking for a code snippet to read the temperature of a CPU. I have a project that trashes the machine and watching the CPU temp seems prudent. I speculate there is a Winbond chip integrated into the motherboard. So the is obviously direct calls to the chip. Perhaps there is an API I can call? Direct reading of the hardware is less desirable than an API as the chip may not be the same in all machines.

    http://www.contract-developer.tk

    C / C++ / MFC css hardware json question

  • Testing if Unicode
    V VeganFanatic

    One other idea that comes to mind try { cout << mystring << endl; catch wcout << mystring << endl; }

    http://www.contract-developer.tk

    C / C++ / MFC testing beta-testing question

  • Exception Handling in C++
    V VeganFanatic

    I tend to use assert a lot to check on things as its one way to keep code from crapping out.

    http://www.contract-developer.tk

    C / C++ / MFC c++ question

  • array => vector
    V VeganFanatic

    That was another waste of time. Sure seems VC 2010 is hostile to data processing.

    http://www.contract-developer.tk

    C / C++ / MFC graphics data-structures
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups