Member Avatar

I'm having the following difficultly: I have a table `rates` which contains the follow: -> id -> rate_from -> rate_to -> price A `user` can have many rates, and for an example: between 0 - 10 hours the `user` charges `10.00` an hour between 10 - 100 hours the `user` charges `20.00` an hour What I want to do is calculate, let's say that the person has worked 40 hours then it would be the following (`10 * 10` + `30 * 20`) But the issue is, how can I achieve this using PHP? They could potentially have worked `48.10` …

Member Avatar
+0 forum 5
Member Avatar

Hi all, I think I might have missed something, I have been away for sometime. I was visiting the site and noticed that I had access to area 51. But I don't seem to recall having any of the privileges mentioned in the description. Is this an error or has the rules changed to whom can access Area 51?

Member Avatar
+0 forum 3
Member Avatar

Assume that I have a vector: x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] What I need to do is split this vector into block sizes of `blocksize` with an `overlap` `blocksize = 4` `overlap = 2` The result, would be a 2D vector with size `4` containing `6` values. `x[0] = [1, 3, 5, 7, 9, 11]` `x[1] = [ 2 4 6 8 10 12]` `....` I have tried to implement this with the following functions: std::vector<std::vector<double> > stride_windows(std::vector<double> &data, std::size_t NFFT, std::size_t overlap) { std::vector<std::vector<double> > blocks(NFFT); for(unsigned i=0; …

Member Avatar
+0 forum 1
Member Avatar

Hey DaniWeb *Never fear, Phorce is here!* I've completely stopped getting emails from you guys when a watched article has been read. I've clicked "Watch article" and everything but still nothing.. Checked my spam folder, nothing. Anyone else facing this issue?

Member Avatar
+0 forum 3
Member Avatar

I don't know why I'm having such a problem with this, basically, I want to have a Queue that is constantly running during the program called "Worker" this then works, however, every 10 seconds or so.. Another method called "Process" comes in and processes the data. Let's assume the following, data is captured every 10 seconds.. (0, 1, 2, 3, ..... n) and then the "Proces" function receives this, processes the data, ends, and then the "Worker" goes back to work and does their job until the program has ended. I have the following code: import multiprocessing as mp import …

Member Avatar
+0 forum 1
Member Avatar

I have two threads, and, I want one thread to run for 10 seconds, and then have this thread stop, whilst another thread executes and then the first thread starts up again; this process is repeated. So e.g. from threading import Thread import sys import time class Worker(Thread): Listened = False; def __init__(self): while 1: if(self.Listened == False): time.sleep(0) else: time.sleep(20) for x in range(0, 10): print "I'm working" self.Listened = True class Processor(Thread): Listened = False; def __init__(self): # this is where I'm confused!! Worker().start() Processer().start() (P.S. I have indented correctly, however, posting seems to have messed it up …

Member Avatar
+0 forum 1
Member Avatar

Loading DaniWeb today was very slow.. Been like it most of the day and I have just been able to get on. mhm. Anyone else?

Member Avatar
+0 forum 2
Member Avatar

My browser does not seem to be making new tabs.. Please see

Member Avatar
+0 forum 1
Member Avatar

I believe there is a function which returns the max value for a double, however, I do not need this. I'm converting the following function: public void StaticCompress(short[] samples, float param) { for (int i = 0; i < samples.Length; i++) { int sign = (samples[i] < 0) ? -1 : 1; float norm = ABS(samples[i] / 32768); // NOT short.MaxValue norm = 1.0 - POW(1.0 - norm, param); samples[i] = 32768 * norm * sign; } } But instead of using `shorts` I pass in a `double` array. Anyone have any suggestions?

Member Avatar
+0 forum 7
Member Avatar

I might be a bit tired, but why does the following not work? class Signal { public: Signal() { } protected: std::vector<double> data; }; class Something : public Signal { public: Something() { data.resize(100); } }; class Parser : public Signal { public: Parser() { std::cout << this->data.size(); } }; int main() { Something w; // resizes vector data to 100 Parser f; // outputs size } Since I call `Something` which resizes the vector.. But, in `Parser` I can't seem to access the `data` member? Arghh! The output is `0` -> If, however, I inherit from `Something` it will …

Member Avatar
+0 forum 3
Member Avatar

I basically have two classes: `Signal` and `Parser` they both have differences, however, they each share the data that `Signal` has. I want to incorperate Method Chaining into the class, so my classes (at the moment look like the following): class Signal { Signal() { } Signal& Parse() { return *(this); } }; And my other class looks like the following: class Parse : public Signal { Parse() { } }; This will therefore allow me to do the following in main: `Signal s = Signal().Parse();` But what I need to do is in the class `Signal` when `Parse` is …

Member Avatar
+0 forum 2
Member Avatar

Earlier today I could not sign in and it told me my username + password combonation wasn't right. But, I had not changed it? It worked after I re-set my password. Nothing changed on my account, so I don't think I've been "Hacked" Any ideas? P.S. now I'm getting a blank chat window.. What is going on?

Member Avatar
+0 forum 5
Member Avatar

I'm working on a project that generates roughly between 13x512 values in which I compare at run-time. So the program outflow will be sort of as follows: - Program executes - Extracts (1) 12x512 - Extracts (2) 12x512 - Compares (1) to (2) - Extract (3) - Compares (3) to (2) (1) The problem is, I don't know whether or not the quickest method would be to store the extracted values inside a text file and then read them in, or, just store inside memory and if I am storing inside memory, is there a quick way to access these? …

Member Avatar
+0 forum 3
Member Avatar

I'm attempting to implement the Factory Pattern. I have a class called "Window" which has a class member function which determines which object is being called and then assigns the particular object pointer. I have written the following code: class Hamming { public: Hamming() { } Hamming(int theSize) { // code } }; class Window { public: Window() { } Window* createInstanceOf(int theWindow, size_t size) { Window* w; w = new Hamming(100); return w; } }; I want to be able to call it from the following: Window* w; w->createInstanceOf(val, val2); I get the following error: error: assigning to 'Window …

Member Avatar
+0 forum 6
Member Avatar

This came across me the other day, and it got me thinking. Let's assume I have a very quick question, for example, I had one the other day: > How much implementation can you actually put inside a constructor? For me, personally, I did not want to make a post about this, as, I wanted a general snappy answer and of course, it is based on peoples opinions etc.. Instead, what I did (shameful) was reach out to a group of C++ developers on Facebook, who, provided me with a quick response in a kind of chat style theme which, …

Member Avatar
+0 forum 1
Member Avatar

Sorry if this is hard to understand what I'm trying to do here, but, I do not know how to approach this. I am using method overloading in my constructors of a class, and I have multiple "Window" functions which are all classes that can be used and I need to initialise an object of one of these classes depending on which is passed through. For example: I have an `enum` which stores the types of Windows available: enum WindowType { Barlett = 0, Blackman = 1, Hamming = 2, Hanning = 3, Nuttall = 4, }; And inside my …

Member Avatar
+0 forum 3
Member Avatar

Hello, I am having a few problems when trying to execute the a Makefile that will *hopefully* create a static library that I can use for future use. Here is my code below: #----------------------------------------------------------------------------- # Usage of make file #----------------------------------------------------------------------------- # Clean operation: # make -f MakeClient clean # # Make operation: # make -f MakeClient # # #OBJ = $(SRC:.cpp=.o) OBJ_DIR = ./obj OUT_DIR= ./lib OUT_FILE_NAME = libclient.a # include directories # C++ compiler flags (-g -O2 -Wall) CCFLAGS := -std=c++0x # compiler CCC = g++ # Enumerating of every *.cpp as *.o and using that as dependency $(OUT_FILE_NAME): …

Member Avatar
+0 forum 1
Member Avatar

So basically, I'm working on a project that can require both arrays and vectors to be passed through in order to calculate the final outcome. Now, I'm using the constructor to calculate the values and I need to know whether or not it is possible to change the datatype of the values depending of that what is passed through the constructor. Example: class FFT { public: FFT(<array> &values_to_be_passed_through || <vector> &values_to_be_passed_through) { this->val = foo; } private: vector/array vals_to_be_passed_through }; int main(int argc, char *argv[]) { int arr[] = {1, 2, 3, 4, 5, ......., 10}; FFT fft(arr); // this …

Member Avatar
+0 forum 4
Member Avatar

I have not visited PHP/MYSQLI for some time now, and, need some guidance on the following problem: I'm trying to retrive all the data from the given week and just in that week. My table looks like the following: id int(11) type varchar(255) week datetime And as a test data I have the following: 1 Sport 2013-05-28 00:00:00 This is within this week, and, therefore should be returned, however, it does not return. Again, I am just getting back into PHP/MYSQLI so there may be a problem with my query, I just cannot seem to figure it out. Here is …

Member Avatar
+0 forum 5
Member Avatar

Hey guys! Just a quick question really: What happened to the spell check when you write in the forum posts? It seems to have gone for me D: even though I recieive the feature in other forums (no names) it's just annoying sometimes because I have to concentrate really hard on spelling (Sorry if there any in this!) Also, is there any plans on building a real-time notification bar?

Member Avatar
+1 forum 19
Member Avatar

Hello, I have a question. I'm not sure I am using the right terms or anything here, but, I have seen people develop their "projects" (classes etc..) and then creating a .dll file (or .lib) and then importing the files when they need them. But I cannot seem to get my head around it.. So for example: class Test { public: Test(); Test(int theVar) { var = theVar; cout << "You entered: " << this->var; } private: int var; }; If I had the class above and wanted to export it as a .dll and then import like this: #include …

Member Avatar
+0 forum 4
Member Avatar

Hello, I don't want to look like I am following other forums, but, wouldn't it be a good idea for users (with a certain amount of rep) to have basic moderation tools, or, atleast the ability to edit posts by users and: 1) The person who posted can accept this edit 2) Other users can vote to say this edit was good 3) A moderator can accept the edit. Just because I see this sometimes: http://www.daniweb.com/software-development/cpp/threads/443078/matrix-multiplication (I am not singling this user out, just a recent example) where the code isn't in code tags. It would be so much easier …

Member Avatar
+0 forum 2
Member Avatar

Hey, I have a function in C that I am trying to convert over to C++. I have done everything, apart from this line: memcpy(mel[i],&temp[melstart[i]],mellength[i]*sizeof(double)); I need a way of copying the elements in temp[melstart[i]] over to a vector of doubles.. Here is the C code: void Setup_Mel(int fft_size, int sample_rate) { int i,j,k,tap; double fmax; double dphi; double fsample; double freq; double temp[fft_size/2]; fmax=2595*log10(8000.0f/700+1); dphi = fmax/17; freq = (double)sample_rate/fft_size; for (i=0; i<16; i++) { melstart[i]=fft_size/2; mellength[i]=0; memset(temp,0,sizeof(double)*fft_size/2); for (j=0; j<fft_size/2; j++) { fsample = 2595*log10(freq*j/700 + 1); if ((dphi*i <= fsample) && (fsample < dphi*(i+1))) temp[j] = (fsample-dphi*i)/(dphi*(i+1)-dphi*i); …

Member Avatar
+0 forum 3
Member Avatar

Hello, So basically, I am trying to create a system based on the Singleton Pattern and I'm confused. If I have an Animal class, as well as a Cat class which is derived from Animal and then using a Singleton class will create a single object of which-ever class has been selected (dog, horse, cat etc..): Animal.h class Animal { public: virtual int age() = 0; virtual void breed() = 0; }; Cat.h #include "Animal.h" class Cat : public Animal { public: Cat(); int age(); void breed(); }; Cat.cpp Cat::Cat(){}; int Cat::age() { return 10; } void Cat::breed() { } …

Member Avatar
+0 forum 8
Member Avatar

Hey, I might be having a blonde moment but here goes.. I'm trying to split a massive 1D vector into blocks at different places (If that makes sense), it should basically go like this: 0 201 401 601 801 .. .. .., 57201 2 202 402 602 .. .. .. .. 3 302 402 602 But, for some reason, it prints out as: 0 1 2 3 .. .. .. Here's a tiny bit of sample code: for(unsigned i=0; (i < numblocks); i++) { for(unsigned j=0; (j < N); i++) { cout << (i*200+j) << endl; } } In my …

Member Avatar
+0 forum 3
Member Avatar

Hello, having a weird problem and wondering if someone can help me.. Basically, I'm trying to read in a .wav file, and I have read in the header information and that's all fine, it's just the data.. Here is the code: bool Wav::readHeader(ifstream &file) { file.read(this->chunkId, 4); file.read(reinterpret_cast<char*>(&this->chunkSize), 4); file.read(this->format, 4); file.read(this->formatId, 4); file.read(reinterpret_cast<char*>(&this->formatSize), 4); file.read(reinterpret_cast<char*>(&this->format2), 2); file.read(reinterpret_cast<char*>(&this->numChannels), 2); file.read(reinterpret_cast<char*>(&this->sampleRate), 4); file.read(reinterpret_cast<char*>(&this->byteRate), 4); file.read(reinterpret_cast<char*>(&this->align), 2); file.read(reinterpret_cast<char*>(&this->bitsPerSample), 4); char testing[4] = {0}; int testingSize = 0; while(file.read(testing, 4) && (testing[0] != 'd' || testing[1] != 'a' || testing[2] != 't' || testing[3] != 'a')) { file.read(reinterpret_cast<char*>(&testingSize), 4); file.seekg(testingSize, std::ios_base::cur); } this->dataId[0] …

Member Avatar
+0 forum 3
Member Avatar

Hello, I'm just wondering whether or not, it is possible to get the vector Dimensions without them being set? Basically, I'm converting some matlab code and there's a function size(VECTOR) which get's the dimentions of the vector being passed. For example: #include <iostream> #include <vector> using namespace std; int main(int argc, char *argv[]) { vector<vector<int> > items; vector<int> theItems(20); for(unsigned i=0; (i < 20); i++) { theItems.push_back(i); items.push_back(theItems); } } I need to determine the dimensions of items. Can I use something like capacity? Or is there a STL function like in matlab where you have size.

Member Avatar
+0 forum 3
Member Avatar

Hello, I'm trying to read the header information of a .wav file and I'm kind of stuck. Basically, the header information is located at different offsets in the file. So for example: (0-4) = ChunkID (4-8) = ChunkSize (8-12) = Format .. .. .. .. .. .. From this: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ Now the problem I'm having is when I try to read the data like this, the data does not store correctly and I end up with missing data. This is the code I have written: bool Wav::readHeader(FILE *dataIn) { // RIFF int i=0; fread(this->chunkId, sizeof(char), 4, dataIn); i += 4; …

Member Avatar
+0 forum 1
Member Avatar

Hello, wondering if someone can help me. I'm working with a .wav file, and, I need to collect the header information. The header contains (roughly, 20 bits/bytes) before the actual data. And, each of this data is contained at different locations in the file. I need to read a particular amount of integers in the text. For example: Data = 102030405060 For the first header information, I need to gather the first 4 integers.. So: Data = { 10 20 30 40 } The code that I have written, reads in the first integers, however, reads them like this: Data …

Member Avatar
+0 forum 1
Member Avatar

Hello, I'm trying to write the Cooley Turkey algorithm for an FFT. Now, The algorithm works well, but, only for 2 numbers - Nothing else. For example, I have used an online FFT calculated, entered the same data and got the same results. Here is the code for the algorithm: #include <iostream> #include <math.h> #include <vector> #include <complex> using namespace std; #define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr; #define pi 3.14159 void ComplexFFT(vector<float> &realData, vector<float> &actualData, unsigned long sample_num, unsigned int sample_rate, int sign) { unsigned long n, mmax, m, j, istep, i; double wtemp,wr,wpr,wpi,wi,theta,tempr,tempi; // CHECK TO SEE IF VECTOR IS EMPTY; actualData.resize(2*sample_num, …

+0 forum 0

The End.