Monday, June 27, 2011

My first Qt app

So with sparse matrix on stands, and summer haunting, something had to be done. Qt haunted my empty brain this time. Simple thought of 'MY' app made me Qt aficionado. Now the thing was, WHAT. I have always been fascinated by numerology, so the track was set.

About the code: a SLOT had to be written, taking input from QLineEdit, and calculating the numerology subsequently displaying it to QLabel via QSpinBox.

The first version of looked something like this:

With a QSpinBox showing the numerological equivalent of QString ( or user Input ).


It had some bugs, specially with QSpinBox, The value can be changed and was not right to use it as an output widget, so here came my second version:

Its cool, QLabel replacing QSpinBox, responding to shortcuts like Alt+C, Alt+Q


would be uploading the codes soon...

Apart from it, I have added restrictions to window size to avoid defacing of the app on maximizing.


Codes
License: GNU GPLv3+ view

PS: Suggest me some more numerological stuffs, to make this a real cool app, looking forwar

Saturday, June 25, 2011

sparse.cpp,

This might be my last post related to sparse.cpp, failing to code as per my expectations and goals this became an idea not so longlived. I would be uploading the working code soon, fixing some errors, or curtailing the erroneous codes.

This blog post may mark an end of coding phase, not the end on sparse.cpp. Any one looking forward to work with me on this, is most welcome :). Please get me on any of the contacts listed below or simply leave a comment, I'll definitely get to you.


twitter
irc: saurabharaiyer
(#nitdgplug on freenode)

Saturday, June 18, 2011

When Network icon is not coming in notification area

No problem, again open the terminal, and type the following commands

  • sudo service NetworkManager start
  • sudo chkconfig NetworkManager on
source:       nitdgplug [google group]
thanks to:   Shreyankg and Arjun Basu


Thursday, June 16, 2011

Adding more flexibility, to #include "sparse.cpp"

This is my third blog post regarding #include "sparse.cpp". I have tried to embed more user friendliness this time. display() function is still giving segfaults, and the definitions of retrieve( int, int ) and remove ( int, int ) are not included in the source.

Complete source code(s)

One major change this time: The code is split into header and definition files.

sparse.h:

 /* 
  *  This program is a part of an attempt to implement Sparse
  *  Matrix in C(plus)(plus)
  *
  *  Copyright 2011 Saurabh Araiyer <sizzsa(at)gmail(dot)com>
  *
  *  Licenced under GNU GPL v3+
  *
  *  Downloaded From http://goo.gl/WNrQZ
  */
 

#include <iostream>
#include <vector>
#include "llnode.cpp"

using std::vector;
using std::cout;
using std::cin;   
/*
 * std::cin and cin::cout to be removed in later phase(s) 
 * included for verbose input
 */

#ifndef SPARSE_H
#define SPARSE_H

template <class T>
class sparse
{
public:
    llnode <T> *root;
    sparse(char cVerbose = NULL);
    sparse(vector <T> , vector <int> , vector <int> );
    ~sparse();
    int insert(T , int, int);
    void dispaly();
    void vertical(int);
    void horizontal(int);
    T   retrieve(int, int);         // Input is Array indeces
    int remove  (int, int);         //Synonymous to delete, input is array indeces

private:
    int m,n;
    llnode <T> *temp;
    int maxval(vector<int>);
    int push(T , int, int);
    int index_return(int, llnode <T>*);
    int incase(int, llnode <T>*, int, int);
};

#endif // SPARSE_H

Monday, June 13, 2011

#include "sparse.cpp" insertion function

This time its happy news for me, all segmentation faults from the insertion function has been resolved, in this version of my code, I have removed the display function, an addition in the form of retrieve function would be done soon, so that values could be fetched from the sparse <type> object.

Click for Source code
All source codes and screenshots

Tuesday, June 7, 2011

#include "sparse.cpp"

I was thinking about 2-D arrays and memory, there it stroke me Sparse Matrix, a relatively efficient way to do so. Then why not develop it, there it started rolling:


Source Code
Mapping of nodes, for easy understandibility

Things done to create a node:
            __________________
            |                |           |
            |                |           |
            |        1      |     2    |
            |                |           |
            |_________|______|
            |         3     |     4    |
            |_________|______|

1. template <class T>class node :: <T> data. //Template
2. template <class T>class node :: node <T> * hnode. //hnode stands for horizontal link to the node
3. template <class T>class node :: node <T> * vnode. //vnode stands for vertical link to the node
4. template <class T>class node :: short int num data. //For tracking node positions


About the code:

sparse is defined as a generic class having

Data variables:

public:
     node <T>* root;
private:
    node <T>* temp;
    int m, n; // to define the maximum size of the sparse matrix


Member Functions:

public:
    sparse();//Constructer
    void insert(int case, T a, int posva,int posha);//for insertion
    void display( void ); //lots of bugs to be fixed in this function
private:
    int insertion ( case 1 , node <T>* a , int pv , int ph )
    int insertion ( case 2 , node <T>* a , int pv , int ph )
    int insertion ( case 3 , node <T>* a , int pv , int ph )
    int insertion ( case 4 , node <T>* a , int pv , int ph )
    int index_return( int ret = 0 , node <T> * a)
    int index_return( int ret = 1 , node <T> * a)


More recent definitions to the code


/* incase i = insertion ( casei )
 *
 * incase 1: when at both positions root->vnode[pv].hnode and  
 * root->hnode[ph].vnode, don't have any node associated with 
 * them
 *
 * incase 2: when root->vnode[pv].hnode is occupied and
 * root->hnode[ph].vnode is free
 *
 * incase 3: when root->hnode[ph].vnode is occupied and  
 * root->vnode[pv].hnode is free
 *
 * incase 4: when both root->hnode[ph].vnode and 
 * root->vnode[pv].hnode are occupied
 *  
 * index_return(0, ... ) returns the current vertical position
 * ( assumed that the mxn matrix created is similar to a 
 * a standing grid )
 *
 * index_return( 1 , ... ) returns the horizontal position of the 
 * node in the matrix grid 
 */


Please suggest me more functions which I may write for increased usability.