DavidB 44 Junior Poster

Good to see you back!

Life is busy for everybody, I think.

Changed jobs, married, moved and busy getting this house in order mostly.

Hopefully, the change of job is to something better, more satisfying, better paying, more convenient location, etc. (Also, if you think you are busy now, wait until you have children!) I wish you all the best.

DavidB 44 Junior Poster

A couple additional comments.

You should check that the calculation of half is really what you want.
The upper limit for the iteration might be DIM/2 - 1.

Also, I'd recommend using a different variable name for max.
max is a predefined function in C++. It takes in two operators and returns the maximum of the two. For example,

dummyVar = max(2, 5); // should return 5

Using it as a variable name might cause issues.

DavidB 44 Junior Poster

I'd recommend sticking with something you know. That way, you don't have to learn a brand-new language from scratch; you can create graphs as quickly and easily as possible. Otherwise, you could probably create graphs with any language, for example, C++, but it would be a major new project.

If you already use Microsoft Excel, why not just import the data to Excel and use some of its graphing capabilities? Or, if you just want a plot of raw data (numbers), you could use a free online tool like Desmos. Otherwise, there are more sophisticated tools available aimed for scientific applications (e.g. Octave, SciLab, etc.)

It all depends what kind of data you are planning to plot, and the type of graph you would like to create.

DavidB 44 Junior Poster

"A while back I looked at SpiderOak which was promising just that in the near future. Perhaps it's time for another look."

I recall that discussion from about a year ago:

https://www.daniweb.com/community-center/geeks-lounge/threads/455113/new-kind-of-dropbox

I have been using SpiderOak and it seems to work fine. Automatically synchs my files whenever a change is made.

Box (box.com) is also nice. I got the free 50 GB for life and am very happy with it. It is very fast and easy to organize files.

DavidB 44 Junior Poster

Each mailbox is either closed or open, so you could represent the mailboxes by an array of ints, which are assigned the value 0 or 1, to represent closed or open. Or an array of booleans. Start by assigning all of them to one value (say, 1) to represent closed. Then go through the loops, and check if closed or open:

if (1) reset value to 0
else reset value to 1

Then just go through all the loops like that. Post your code as you go so we can offer suggestions.

DavidB 44 Junior Poster

Even if we wanted to work through this problem for the OP, I don't think there is enough information to answer the question.

We don't know how much the seller marked it up in the first place.

DavidB 44 Junior Poster

It can also be done by postal code.
For example, in the US, the ZIP code is used for accurately locating a region. I believe it is established by the USPS, but other shipping companies use it too (e.g. UPS, FedEx, etc.)

It started out as a 5-digit code but has since expanded to a 5 + 4 system: e.g. - 80302-8761

Once you are in a particular zip code, you can refine a location to the street number, and unit number:

123 Main Street
Unit #403
etc.

Other countries use postal codes, but organize them slightly differently. For example, I believe Germany's system is based on proximity to a large urban center. So Munich city center might be 80000 and outlying areas would be defined in relation to 80000: 800023, 80875, etc. It is pretty logical once you understand it. Makes more sense to me than the English and Canadian system, which uses postal codes like M5B 4W6, etc.

DavidB 44 Junior Poster

Wolfram Rösler created a similar collection on his web site:

The Hello World Collection

It includes credits, and a link to similar collections (including Wikipedia.)

DavidB 44 Junior Poster

"Is the TAB going to replace the laptop?"

No, I don't think so.
I couldn't program on a tablet. Even a laptop is a bit awkward. I don't like being hunched over for hours when I am trying to write code. My preferred machine for serious code-banging is a still a desktop; with that, I can sit up straight, be comfortable, think clearly, and get better work done.

The only time I would consider getting a tablet or something similar, is if I were shopping for my children (8 - 12 years old). In that case, I'd go for a Chromebook (about $300): no operating system, no viruses, etc. everything is in the cloud. Most of the time they are just watching videos or playing games, so they don't need all the professional software packages anyhow.

DavidB 44 Junior Poster

The use of a URL Shortener, by itself, is not spam. It is used for many legitimate purposes (e.g. - in Twitter, to keep tweets within the 140 character limit).

And they are offered by many different sources; in fact, even Google provides one (goo.gl). I don't think Google would offer a product that is considered solely a spam tool.

HOWEVER, if you submit a URL--shortened or not--to a multitude of sites, or post it all over the blogosphere, or post it in many forums and it is not relevant to the conversation taking place, then it will be considered spam.

As always, use good judgement and make sure the link you are submitting fits into the page to which you are submitting it.

DavidB 44 Junior Poster

Hmmn... I am not clear what is happening.

I have a blog on Blogger (see my Profile) and it displays the Description as expected. Under the name of my blog, it correctly displays the description, "Living a quiet life in Coquitlam, B.C."

Is yours not displaying at all?
If you delete the Meta tag description, does it then display properly?
If you re-add the Meta tag description, does it overwrite the main description?

DavidB 44 Junior Poster

Are you willing to purchase a compiler? If so, there are some commercial products available, for example, Pro Fortran 2014: http://www.absoft.com/

Otherwise, you might be interested in Open Watcom. I don't have extensive experiences with it myself. I downloaded it a couple years ago to test original Fortran code against my C++ translations but, other than that, haven't used it much. Still, it might suffice for your purposes.

DavidB 44 Junior Poster

I experienced a similar problem some time ago (trying to get data off a crashed harddrive on a Dell laptop).

However, I didn't even try to fix it myself; I brought it in to a local computer repair store, they moved the hard drive in to a comparable Dell laptop, and were able to copy most files on to a USB drive. I don't know all the software packages they used in the process.

It might be best to go to a professional. All the tinkering you do trying to do it yourself might just make it harder to recover data when you do bring it in to a pro.

Since then, I have been very anal about backing things up--on a USB drive and in the cloud.

DavidB 44 Junior Poster

You might also want to consider an online presence manager like about.me:
https://about.me/

Then you could create whatever image you want as a background, supply whatever information about yourself you want made public, and then put a link to your Profile page in your signature. It's a slick way of creating an online Profile that doesn't have to be repeated each time you join a new site or forum.

I suppose you could do something similar with Gravatar (http://en.gravatar.com/) too.

Or your Facebook page.
Why not use that graphic on your Facebook page, put whatever information you want made public on your Facebook page, and then put that link in your signature? It would save you the trouble of duplicating your work? (Why re-invent the wheel?)

DavidB 44 Junior Poster

RAND_MAX is defined in <stdlib.h>, which you have to include in your program to use rand() anyhow. So you don't have to include anything additional.

RAND_MAX is the largest number that can be output by rand(). You should check out your documentation for more detailed information.

DavidB 44 Junior Poster

rand() gives an integer between 0 and RAND_MAX.

To get a number between 0 and 25, I'd do something like the following:

1) Divide the output of rand() by RAND_MAX to get a number between 0 and 1.
2) Multiply the result by your desired maximum, in this case, 25.

i.e. -

randNum = (rand()/RAND_MAX)*25;

This code might need some tweaking. Play around with it a bit to get it doing what you want. (round, floor, etc, the result to get an integer)

DavidB 44 Junior Poster

Hi, Louis.

Years ago, when I first joined Daniweb, I think all discussions for the less-popular languages were thrown into the "Legacy Languages" forum:

"Software Development" -> "Legacy Languages"

That is where you'll find any questions relating to MATLAB, MathCAD, AutoCAD, etc. As far as I know, there simply isn't enough ongoing discussion on these topics to justify creating separate forums for them.

DavidB 44 Junior Poster

What is telling you not to use short.MaxValue? The compiler?

Perhaps you could use a macro instead. This is what is in <cfloat> itself:

#define DBL_MAX 1.7976931348623158e+308

Include <cfloat> in your program, use DBL_MAX in that line, and see what happens.

DavidB 44 Junior Poster

I think it is 1.79769e+308.

You can access it via numeric_limits::max

i.e. -

#include <limits>

If you then output a statement for this limit for type double, it should give the number I gave up top.

DavidB 44 Junior Poster

What kind of answer are you looking for? An exact time in milliseconds? I don't think anybody could give that kind of answer. It would depend upon the hardware you use and several other factors.

Are you supposed to write a program execution timer? You'd have to get a hook into the clock cycles of your computer and take the time before and after the code block executes.

Or are you just looking for the order of the algorithm? For example, order 0.618*n, n, n log(n), log(n) log(n), etc.?

DavidB 44 Junior Poster

I personally think they should be left alone. . . .

Agreed. The West should get out of the habit of meddling. And the fact is, we simply cannot afford to do it anymore.

We should let somebody else take a turn shouldering the burden of settling conflicts. China sells their goods all over the world and is getting rich doing so. Why can't they pay the cost of policing a region for a change? Or Russia? They have a stake in the region too, but aren't talking about going in there to settle things. Perhaps they believe things will get settled--by themselves--without costing any Russian men or rubles. Either way, people are going to get killed.

And why are we now so concerned that people were killed by gas? Nobody would be as excited if the same number of people were killed by a big explosive device.

I wonder why some nations seem content to let others kill each other, while western nations feel the need to do something about it. Are those nations simply more cold-hearted than we are? Or do they know something we don't?

DavidB 44 Junior Poster

What are you doing now (i.e. - grade in high school, college, etc)?

If you are sure you want to pursue a career in Computer Science, I suggest you start exploring Linux. It is not exactly Computer Science, but most jobs in the field like to see somebody with some knowledge of Linux. All the programming courses I took (Mac Pascal, FORTRAN, Pascal, C, C++, etc.) always covered the same bases: do loops, for loops, while loops, pointers, arrays, subroutines, etc. The syntax was slightly different, but the logic was similar. I thought most of the courses after the first one were just a waste of time, since they were just repeating what I already learnt in the first course.

If you get a job using existing applications, or purely writing code, consider yourself lucky.

However, in many situations, you will end up working in some industrial application: remote control, telephony, web applications, communications, game development, real-time robotics, etc.-- all of which will require knowledge of Linux or Unix (Windows is not good for real-time applications).

Here's an idea: pretend you are a graduate right now, and you are looking for work. Spend some time in the job boards (monster, careerbuilder, etc.) and see what requirements are listed for job-postings that you like. I think you'll see a lot of them include Linux experience as a requirement or a "nice to have."

And the nice thing about playing with Linux is that you can do it on your own, constantly--even …

DavidB 44 Junior Poster

I do not know if there is a hard and fast rule about when to break JavaScript code blocks into separate files.

If you are doing this work for an employer, they may have policies regarding when and how to break code up into individual files.

Myself, I often break code up by common sub-routines. For example, I have separate files for routines that (i) input data for a square matrix, (ii) output a square matrix, (iii) input a vector, (iv) output a vector, etc. That way, when I write a new page that may need these tasks done, I don't have to include the whole routine in each new program. I just reference the external .js file. Makes the file size of each page smaller, and saves space on the server.

Plus, using external files make re-loading the pages faster. The .js files are kept in the browser cache and don't have to be re-loaded each time.

DavidB 44 Junior Poster

I am sure all the prestigious universities are comparably excellent (Oxford, Cambridge, etc.).
Do you have a particular preference for where you want to go within the field of Computer Science (CS)?
For example, Loughborough is pretty well-known for aerospace, so a CS degree there might be designed more for engineering applications.

Perhaps ask your question in a forum specifically for university students. The Student Room (thestudentroom.co.uk) is the biggest student forum I know of, and it happens to be based in the UK. Somebody there probably has personal experience with UK universities and can offer better information.

DavidB 44 Junior Poster

I don't use any online storage but I would imagine SpiderOak is preferable to DropBox. SpiderOak uses on-the-fly encryption . . .

Nice. I will have to check that out; I hadn't heard of SpiderOak before.
I presently use Google Drive, ADrive, Box, and My Shoebox (shoeboxapp.com) for photos, but it is always good to know about more options.

Regarding privacy, I don't worry too much about it. I don't save documents with deep dark secrets anyhow. I mainly just treat it as a back-up in addition to a USB, in case my computer crashes or my home burns down.

Anything more personal or private I would encrypt anyhow (addresses, phone numbers, business contacts, website log-ins, etc).

DavidB 44 Junior Poster

Are you the author of the program?
If so, why not just initialize everything at the beginning of the program so you don't have to wonder?

Are the data types all going to be numeric, as in your example?

I don't think there is an easy way to do it. Off the top of my head, one way would be to assign a Boolean variable to each variable to indicate if it has been initialized or not.

If the variables are all numeric, you might try using isnan() in <cmath>.

Also, this might interest you, and it is relevant:
Yesterday when I was looking for information about quiet_NaN, I came across several informative threads on stackoverflow. You might want to head over there and do a search for "quiet_NaN". Here are some of the more interesting/relevant threads:

http://stackoverflow.com/questions/7893531/what-is-the-best-way-to-indicate-that-a-double-value-has-not-been-initialized/7893598#7893598

http://stackoverflow.com/questions/235386/using-nan-in-c

http://stackoverflow.com/questions/6822044/c-checking-if-a-variable-is-initialized/6822126#6822126

http://stackoverflow.com/questions/235386/using-nan-in-c#236952

The post by "Motti" in the last thread has been upvoted a lot, so it might be worth investigating more thoroughly.

DavidB 44 Junior Poster

Interesting article. This is the first I have heard about spicy food affecting cancer.
I have read of several other foods that supposedly prevent cancer: eggplant, bitter almonds, apricot seeds, graviola, etc. Don't know if they are actually effective.
Plus, sugar should be avoided. Apparently, cancer cells use five times as much sugar as regular cells to grow. And with all the sugar in our diets, we are making a comfortable home for cancer cells. So I have tried to drastically reduce my sugar intake.

DavidB 44 Junior Poster

Do you Like Wine and Bear ?

Bear??!!

I have never had it. Does it taste anything like chicken? If so, then, yes, I like it. Especially with a little paprika sprinkled on it.

DavidB 44 Junior Poster

I think one way would be to just provide an example, wouldn't it? For example,

2^2 + 3^2 = 4 + 9 = 13

13 is a positive integer, so you have proved that there is a positive integer that can be expressed as the sum of the squares of positive integers.

In fact, the sum of squares of any integers (x, y, z, etc.) is always a positive integer:

x^2 + y^2 + z^2 + . . . is always going to be a positive integer.

The only way for it not to be a positive integer would be if x, y, z, etc. were non-integer numbers.

DavidB 44 Junior Poster

Do you need to save the numbers as they are entered?
If not, you only need one input variable and one sum variable.

Also, will you always take in only four variables, or an unknown number of variables?

I would do something similar to the following:

int a, isum = 0;
cout << "Enter some postive integers & I'll print the sum: ";
cin >> a;      
while ( a > 0) {
 isum += a;
 cin >> a;
 }
cout << "The sum is: " << isum << endl;
DavidB 44 Junior Poster

I don't know if you can do this, using the existing format. You could probably divide names up by line breaks, but then dividing names into first, middle, and last names would be difficult. You would have to require users to input the names in a particular format. Otherwise, the program has no way to know if a first name is, say, "Ma. Rex" or just "Ma." Or if the last name is "Cambarijan" or "III".

How is this input coming in to the program? From a textarea box? Text boxes?

DavidB 44 Junior Poster

Like WaltP already suggested, go through your code and find all the places where division occurs. I see it on lines 25 and 43. Insert a line or two before the division statements that check to see if the denominator is 0:
e.g. - if (a[i][i] == 0) printf("\nAttempted division by zero. Execution aborted.");return 0;

Or something like that. That way your program doesn't just crash.

In any case, you are not going to be able to solve this equation completely. To solve for N variables, you need N equations. You have a 3X4 matrix (I think), so you will not be able to solve uniquely for all the variables. Is your system 3X4? The a matrix is 5X5, the x vector is 3, and your comment for the data entry indicates a 3X4 system. Which is it?

DavidB 44 Junior Poster

You are using the exact same form element name for the checkbox and the textboxes:

if (theForm.DigRacing.checked) {
   total += parseFloat(theForm.DigRacing.value);
}
if (theForm.AtariJoystick.checked) {
   total += parseFloat(theForm.AtariJoystick.value);
}
if (theForm.FXLightsaber.checked){
   total += parseFloat(theForm.FXLightsaber.value); 
}

Shouldn't they be different?

What kind of errors are you getting?

DavidB 44 Junior Poster

Is the error during compilation, or during execution?
What is the error message?

Taking a quick look at the code--and maybe I am mistaken--but the closing brace on line 28 seems to match the opening brace for the for loop on line 24. Or is that for the if statement on line 22?

As a first step, double-check to see all your closing braces are where they should be.

DavidB 44 Junior Poster

I don’t know about the memory- and time-efficiency aspects, but using const is supposed to be best practice.

I suggest getting in the habit of favouring the compiler instead of the preprocessor, or getting the compiler to do as much of your work as possible.

As has been indicated already:

- if you use a const variable, and then somehow change the value of that variable later in the program, the compiler will complain (in other words, the compiler will catch your mistake and help you out)

- if you use const, and there is a problem with the variable during compilation, the compiler will let you know there is a problem with it by name. On the other hand, if you use a macro, the symbolic name may never be seen by the compiler and entered in the symbol table. If that variable causes an error during compilation, the error message might refer to 1, 2, 3, 4, etc. -- or whatever number is assigned to the symbolic name by the define statement. If you receive a message like “Error with 1”, tracking down that error is a lot harder than an error message like “Error with EnumTypeOne”.

Get the compiler working for you; not against you.

DavidB 44 Junior Poster

I took a very quick look through your code, so did not make sure all braces matched up.

However, I think one error might be on line 16:

if(wh[j].amt[i]>0 && quantity<=wh[j].amt[i])

The very first time through the loop, j is 0. But you checked wh[0] in the previous test block; it was the very first warehouse you checked. So this test condition fails the first time through the loop.
So the program jumps to the else block:

cout<<"Order Unfilled\n";
quantityamount1[i]=1;
break;

The program outputs "Order Unfilled" and then breaks out of the loop.

I don't think there is a need to use a break here. You want to cycle through the rest of the wh[j] warehouses don't you? So remove the break, and let the for loop continue going through the rest of the warehouses. You only need a break if you find a non-empty warehouse and then want to avoid searching the rest of the warehouses.

It would probably be best if that block was not in the for loop at all, because it only applies after looping through all the warehouses. Maybe you could use a flag variable to keep track if a warehouse is eventually found, or you could use the j variable.

DavidB 44 Junior Poster

Hmmnn...

I thought I was pretty good at math, but I don't understand this question.
It almost looks more like a mathematics question than a computer science question.

Just out of curiousity: what are you studying? And what level are you?

DavidB 44 Junior Poster

The code looks okay--assuming no errors or exceptions occur. However, better code would deal with the possibility that errors or exceptions might occur and, if they do, deal with them gracefully. There are three examples posted off the following page:

Dynamic Arrays in C++ - Three Examples

You might want to check them out.

DavidB 44 Junior Poster

So the code compiles and executes without errors? It works perfectly?
In that case, the next aspect I might consider is that perhaps the section of code you are testing executes so fast, the result rounds to zero. Are you sure the code does not execute nearly instantaneously? Perhaps compute a transcendental function like sin(x) a thousand times to give it a bit of a work out. Then you should know for sure that execution is taking some time. If the result is still 0, then I am not sure what else to suggest.

DavidB 44 Junior Poster

You seem to be on the right track. I gave your code a quick look over and a few things caught my eye:

1) You use a variable called "array_size" in the for loops, but I don't see it defined beforehand.

2) Instead of using the magic number 5 throughout the program, why not define an integer constant and assign it the value 5.

3) Why do you call "findLowest(input, 5)" twice, on lines 26 AND 27? I think you could just delete line 26. After all, you are assigning its output to "lowest" anyhow.

4) Same for "getNumAccidents(num_acc, 5)": why call it twice (lines 21 and 22)?

DavidB 44 Junior Poster

Hello, "jmrpjb".

Welcome to the DaniWeb forums.

Glad you joined.

There is a lot of good information here and many knowledgeable members. I am sure, whatever your "cyber" problems, somebody here will be able to help you.

See you around the forums.

DavidB 44 Junior Poster

Hi, Monty.

Welcome to the DaniWeb forums.

You will find a lot of good information here.

Electrical Engineering, eh?! Well, you picked an engineering discipline in which the job prospects should be excellent.

Best of luck to you!

DavidB 44 Junior Poster

Do you need eigenvectors and eigenvalues?
Is your matrix real?
I translated some code into C++. It takes a real symmetric matrix and computes eigenvalues only. It uses the old method of creating dynamic arrays, checking for NULL, which is not the latest and greatest technique, but otherwise the program works:

Eigensystem Solver Code for Real Symmetric Matrix

Alternately, you might want to check out the Boost and NIST TNT
libraries.

DavidB 44 Junior Poster

. . .
else if ((addteam.teamamanger.value.length < 3) || (addteam.teammanager.value.length > 20))
. . .

Misspelling "manager" probably doesn't help.

DavidB 44 Junior Poster

MATLAB has an "area" function, but I think it requires a known function, which doesn't help you, since your data is experimental.

I am not aware of MATLAB having the sort of function you want, unless they have added this capability recently.

You might want to check out PCHQA:

http://www.ewp.rpi.edu/hartford/~ernesto/ernesto/Courses/C_S97/nc/NMS/CH04/pchqa.f

It accepts experimental data, and does a numerical integration on it, creating an interpolating spline wherever data is needed in order to give the results meaning. (If the integration used only the data points, the results would probably be meaningless, so the algorithm must interpolate at certain points in order to give the results meaning.)

However, there is one drawback: PCHQA is written in FORTRAN

DavidB 44 Junior Poster

What, exactly, doesn't work? The input portion?
Once you input the data, have you outputted it to check if it is wrong or right?

Perhaps you could post the code you have already written, to give us something to work with.

DavidB 44 Junior Poster

It talked about the Mayan calendar and that it abruptly ends in 2012.

It is not the end of the world; it is the end of an age. There have been four ages before the present one; we are presently in the fifth age, which is supposed to end December 21, 2012. The previous four ages all ended in some sort of natural calamity: water, wind, quakes and storms, wild animals. . .

The first age was the Age of the White Haired Giants;
the second age was the Golden Age;
the third age was the Age of the Red Haired People;
the fourth age was the Age of the Black Haired People.

A Google search on “Mayan calendar” turns up many good links. The Wikipedia entry is quite informative:

http://en.wikipedia.org/wiki/Maya_calendar

There is also an interesting calendar at the following link, on which are listed significant events from the Mayan calendar, the Christian calendar, the Jewish calendar, and as well as astrological events:

http://www.diagnosis2012.co.uk/cal.htm