This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:fall2017:discrete:projects:pnc2 [2017/07/13 20:22] – [Displaying the runtime] wedge | haas:fall2017:discrete:projects:pnc2 [2017/09/18 15:58] (current) – [Evaluation Criteria] wedge | ||
---|---|---|---|
Line 1: | Line 1: | ||
<WRAP centeralign round box> | <WRAP centeralign round box> | ||
< | < | ||
- | < | + | < |
</ | </ | ||
~~TOC~~ | ~~TOC~~ | ||
- | ======Project: | + | ======Project: |
=====Errata===== | =====Errata===== | ||
Line 14: | Line 14: | ||
====Revision List==== | ====Revision List==== | ||
- | * revision 0: initial release (20170713) | ||
* revision #: < | * revision #: < | ||
Line 29: | Line 28: | ||
* if optimizing for (or trying to take up less) space, the program runtime can grow. | * if optimizing for (or trying to take up less) space, the program runtime can grow. | ||
- | Let it be clear: using modern computers bound by fourth dimensional constraints, | + | Let it be clear: using modern computers bound by these so-called |
In the previous projects, we focused on algorithms that were more constrained by time- taking progressively more time the larger the data set to be processed became. These time-constrained algorithms also happen to be the type of algorithm you're most familiar with (or at least, were indoctrinated into thinking with...). Your third grade self, on the other hand, potentially would have found more familiarity with the space-constrained methods this project will explore. | In the previous projects, we focused on algorithms that were more constrained by time- taking progressively more time the larger the data set to be processed became. These time-constrained algorithms also happen to be the type of algorithm you're most familiar with (or at least, were indoctrinated into thinking with...). Your third grade self, on the other hand, potentially would have found more familiarity with the space-constrained methods this project will explore. | ||
Line 47: | Line 46: | ||
* unless otherwise specified, you are doing all values (odds AND evens). | * unless otherwise specified, you are doing all values (odds AND evens). | ||
- | * if you exceed some threshold of values get " | + | * if you exceed some threshold of values |
- | * as the space-based approach to solving our prime number computation problem is fundamentally different from those we took in previous projects, you will want to look to start from scratch. Trying to reuse old code and shoehorn it into what effectively amounts to an entirely different paradigm will create a lot of problems. | + | * as the storage-based approach to solving our prime number computation problem is fundamentally different from those we took in previous projects, you will want to look to start from scratch. Trying to reuse old code and shoehorn it into what effectively amounts to an entirely different paradigm will create a lot of problems. |
- | But, the conceptual level, at least for the baseline implementation, | + | But, the conceptual level, at least for the baseline implementation, |
You may find some of the previous optimizations aren't even applicable based on how this algorithm works (break on composite, for instance). | You may find some of the previous optimizations aren't even applicable based on how this algorithm works (break on composite, for instance). | ||
+ | |||
=====Sieve of Eratosthenes (primesoe)===== | =====Sieve of Eratosthenes (primesoe)===== | ||
Your next program, and first sieve, will be the Sieve of Eratosthenes. Perhaps among the best and likely longest-known sieves, its origins date from antiquity. | Your next program, and first sieve, will be the Sieve of Eratosthenes. Perhaps among the best and likely longest-known sieves, its origins date from antiquity. | ||
Line 86: | Line 86: | ||
This is a space-constrained algorithm, therefore we will need a chunk of space to store these values. Think about what a lot of this looks like with respect to how you know how to organize data. | This is a space-constrained algorithm, therefore we will need a chunk of space to store these values. Think about what a lot of this looks like with respect to how you know how to organize data. | ||
- | =====Optimizations on sieve of Eratosthenes===== | + | =====prime algorithm optimizations===== |
- | Not only do we have a new algorithm | + | To give us a decent appreciation of the subtleties of algorithm |
- | ====odds-only processing (primesoeo)==== | + | |
- | Taking the **primesoe** codebase, enhance it to do odds-only processing, ideally considering overall storage used. | + | |
- | ====sqrt() trick (primesoes)==== | + | For simplicity, I have encoded this information in the file name (and therefore resulting executable/ |
- | Taking the **primesoe** codebase, enhance it to utilize | + | |
- | NOTE: this variant | + | To break it down, all prime programs will be of the form: |
+ | * primeALG[O...] | ||
+ | * where each and every program starts with " | ||
+ | * is immediately followed by a 3-letter (lowercase) abbreviation of the algorithm | ||
+ | * and then is followed by 0 or more layered attributes describing the particular optimization that is applied (again, if any: **zero** or more). | ||
- | ====approximated square root trick (primesoea)==== | + | The optimizations we will be implementing in this project |
- | Taking the **primesoe** codebase, enhance | + | * **odds-only checking (o)** - aside from **2**, **all** other prime numbers are odd. Therefore, there is zero need to perform a composite check on an even number, allowing us to focus exclusively on odd values (luckily, they seem to occur in a predictable pattern). |
+ | * **sqrt() trick (s)** - mathematically | ||
+ | * **sqrt()-less square root approximation (a)** - **sqrt()**, a function in the math library, does an industrial strength square root calculation. We don't need that, merely a whole integer value corresponding | ||
- | NOTE: this variant is still to process all values (odd and even). | + | Unless specified in the encoded name, your algorithm should only implement the algorithm |
- | ====odd + sqrt() trick (primesoeos)==== | + | That is, if your program to implement is **primesoeo**, that means you are ONLY to implement the sieve of Eratosthenes algorithm |
- | Modify | + | |
- | ====odd + approximated square root trick (primesoeoa)==== | + | On the other hand, if your program to implement is **primesoeos**, that means your are implementing |
- | Modify | + | |
+ | Some of these optimizations can co-exist easily (odd + sqrt(), odd + approx square root), | ||
- | =====Program===== | + | For this project, you'll be implementing various combinations of optimizations, |
+ | |||
+ | =====A note on comments===== | ||
+ | Something I noticed (and have historically noticed) in relation to comments that I'd like to point out: | ||
+ | |||
+ | Comments should be describing what is going on in your code. | ||
+ | |||
+ | With projects like this, often relying on a common base, comments become even more important, as they allow me to see specifically what is changed or unique about one variant over the other. | ||
+ | |||
+ | As such, when evaluating the project, I will be looking for pertinent comments specifically covering the how or why of the particular change unique to the variant in question. | ||
+ | |||
+ | And notice I said the " | ||
+ | |||
+ | * WHY is that important to the process? | ||
+ | * HOW does it impact the efficiency of the algorithm? | ||
+ | |||
+ | These are things I'd like to see addressed in your comments, as there were some cases where the WHAT was claimed, yet what actually followed had little resemblance (if any) on the requirements for that variant. | ||
+ | |||
+ | Just like if you can't do it by hand you have no business trying to code it- if you cannot adequately explain the WHY and HOW, you similarly will have trouble. | ||
+ | |||
+ | =====Programs===== | ||
It is your task to write the following Sieve of Eratosthenes-oriented prime number calculating programs: | It is your task to write the following Sieve of Eratosthenes-oriented prime number calculating programs: | ||
Line 117: | Line 139: | ||
* **primesoeos.c**: | * **primesoeos.c**: | ||
* **primesoeoa.c**: | * **primesoeoa.c**: | ||
- | |||
====Program Specifications==== | ====Program Specifications==== | ||
- | Your programs | + | Your program |
* obtain 2-4 parameters from the command-line (see **command-line arguments** section below). | * obtain 2-4 parameters from the command-line (see **command-line arguments** section below). | ||
* check to make sure the user indeed supplied enough parameters, and exit with an error message if not. | * check to make sure the user indeed supplied enough parameters, and exit with an error message if not. | ||
* argv[1]: maximum quantity of primes to calculate (your program should run until it discovers **that** many primes). | * argv[1]: maximum quantity of primes to calculate (your program should run until it discovers **that** many primes). | ||
* this value should be an integer value, greater than or equal to 0. | * this value should be an integer value, greater than or equal to 0. | ||
- | * if argv[1] is 0, disable the quantity check, and rely on provided lower and upper bounds (argv[4] would be required in this case). | + | * if argv[1] is 0, disable the quantity check, and rely on provided lower and upper bounds (up to argv[4] would be required in this case). |
- | * argv[2]: reserved for future compatibility; | + | * argv[2]: reserved for future compatibility; |
- | * argv[3]: **conditionally optional** lower bound (starting value). Most of the time, this will probably be **2**, but should be a positive integer greater than or equal to 2. This defines where you program will start its prime quantity check from. | + | * argv[3]: **conditionally optional** lower bound (starting value). Most of the time, this will probably be **2**, but should be a positive integer greater than or equal to 2. This defines where your program will start its prime quantity check from. |
* if omitted, assume a lower bound of **2**. | * if omitted, assume a lower bound of **2**. | ||
* if you desired to specify an upper bound (argv[4]), you obviously MUST provide the lower bound argument under this scheme. | * if you desired to specify an upper bound (argv[4]), you obviously MUST provide the lower bound argument under this scheme. | ||
* argv[4]: **conditionally optional** upper bound (ending value). If provided, this is the ending value you'd like to check to. | * argv[4]: **conditionally optional** upper bound (ending value). If provided, this is the ending value you'd like to check to. | ||
- | * If doing a quantity run (argv[1] NOT 0), this value isn't necessary. | + | * If doing a quantity run (argv[1] |
* If doing a quantity run AND you specify an upper bound, whichever condition is achieved first dictates program termination. That is, upper bound could override quantity (if it is achieved before quantity), and quantity can override the upper bound (if it is achieved before reaching the specified upper bound). | * If doing a quantity run AND you specify an upper bound, whichever condition is achieved first dictates program termination. That is, upper bound could override quantity (if it is achieved before quantity), and quantity can override the upper bound (if it is achieved before reaching the specified upper bound). | ||
* for each argument: you should do a basic check to ensure the user complied with this specification, | * for each argument: you should do a basic check to ensure the user complied with this specification, | ||
Line 142: | Line 163: | ||
* if argv[4] is not needed, ignore (no error displayed nor forced exit, as it is acceptable defined behavior). | * if argv[4] is not needed, ignore (no error displayed nor forced exit, as it is acceptable defined behavior). | ||
* In these error messages, **PROGRAM_NAME** is the name of the program being run; this can be accessed as a string stored in **argv[0]**. | * In these error messages, **PROGRAM_NAME** is the name of the program being run; this can be accessed as a string stored in **argv[0]**. | ||
- | | + | * implement ONLY the algorithm and optimization(s) specified in the program name. We are producing multiple data points for a broader performance comparison. |
- | * start your stopwatch (see **timing** section below). | + | |
- | * perform the correct algorithm against the input(s) given. | + | * immediately after argument processing: |
- | * display to STDOUT (file pointer **stdout**) the prime numbers calculated. | + | * perform the correct algorithm |
- | * stop your stopwatch. Calculate the time that has transpired (ending time minus starting time). | + | * utilize meaningful variable names (I do not want to see things like **a**, **i**, **n**, **x** being used which have no meaningful bearing on the role they serve). |
- | * output the processing run-time to STDERR (file pointer **stderr**). | + | * display |
+ | * stop your stopwatch | ||
+ | * output the processing run-time to the file pointer | ||
* your output **MUST** conform to the example output in the **execution** section below. This is also a test to see how well you can implement to specifications. Basically: | * your output **MUST** conform to the example output in the **execution** section below. This is also a test to see how well you can implement to specifications. Basically: | ||
* as primes are being displayed, they are space-separated (first prime hugs the left margin), and when all said and done, a newline is issued. | * as primes are being displayed, they are space-separated (first prime hugs the left margin), and when all said and done, a newline is issued. | ||
* the timing information will be displayed in accordance to code I will provide below (see the **timing** section). | * the timing information will be displayed in accordance to code I will provide below (see the **timing** section). | ||
+ | |||
+ | =====Implementation Restrictions===== | ||
+ | |||
+ | As our goal is not only to explore the more subtle concepts of computing but to promote different methods of thinking (and arriving at solutions seemingly in different ways), one of the themes I have been harping on is the stricter adherence to the structured programming philosophy/ | ||
+ | |||
+ | As such, the following implementation restrictions are also in place: | ||
+ | |||
+ | * focus on **if()**, **ternary**, | ||
+ | * keep your use of **continue** and **break** statements (especially **break** statements) to a necessary minimum). | ||
+ | * absolutely **NO** other non-structured program flow alteration (jumps, gotos, etc.) | ||
+ | * absolutely **NO** infinite loops (**while(1)**, | ||
+ | * no forced redirection of the flow of the process (no seeking to the end of the file to grab a max size only to zip back somewhere else: deal with the data in as you are naturally encountering it). | ||
+ | * All " | ||
+ | * **NO** logic shunts (ie having an if statement nested inside a loop to bypass an undesirable iteration)- this should be handled by the loop condition! | ||
+ | * At most, **ONE** return statement per function (in the case of **void**, 0 return statements). | ||
+ | * No redundant duplication of code to address different top-level conditions or operational constraints (think quantity vs. range- these can successfully co-exist in the same block of code). | ||
+ | * Never leave an initialized or allocated resource unverified- always do proper error checking (was the file successfully opened? Was the memory successfully allocated? | ||
+ | |||
+ | A common resistance or complaint I get with imposing these is that it may make your solutions more cumbersome or less optimal; that actually may not be an incorrect assertion, but remember: we are interested in the longer-term pursuit of structured thinking and effective problem solving. To foster your ability to think flexibly and differently. We tend to be naturally more averse to going against the grain, but to be an effective programmer/ | ||
+ | |||
+ | I am seeking to make you all better thinkers and programmers, | ||
=====Grabit Integration===== | =====Grabit Integration===== | ||
Line 158: | Line 202: | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | make: Entering directory '/ | + | make: Entering directory '/ |
- | ‘/ | + | Commencing copy process for SEMESTER |
- | ‘/ | + | -> Creating project |
- | ‘/ | + | |
- | ‘/ | + | |
- | ‘/ | + | |
- | make: Leaving directory '/ | + | |
- | lab46: | + | *** Copy COMPLETE! You may now go to the '/home/USER/src/discrete/pnc2' directory *** |
- | lab46: | + | |
- | Makefile | + | make: Leaving directory '/ |
- | lab46: | + | lab46: |
+ | lab46: | ||
</ | </ | ||
- | Furthermore, | + | NOTE: You do NOT want to do this on a populated |
+ | |||
+ | And, of course, your basic compile and clean-up operations via the Makefile. | ||
+ | |||
+ | =====Makefile operations===== | ||
+ | Makefiles provide | ||
+ | |||
+ | Basic operation of the Makefile is invoked by running the command "**make**" by itself. The default action is to compile everything in the project | ||
+ | |||
+ | Additional options are available, and they are provided as an argument to the make command. You can see the available options by running "**make | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | ‘./ | + | ******************[ Discrete Structures pnc2 Project ]****************** |
- | ‘./ | + | ** make - build everything |
- | ‘./ | + | ** make showerrors |
- | ‘./ | + | ** make debug - build everything with debug symbols |
- | ‘./ | + | ** make checkqty |
- | ‘./ | + | ** make checkrange |
- | ‘./ | + | ** ** |
- | lab46: | + | ** make verifyqty |
+ | ** make verifyrange | ||
+ | ** make verifyall | ||
+ | ** ** | ||
+ | ** make link - link in previous prime programs | ||
+ | ** make delink | ||
+ | ** ** | ||
+ | ** make save - create a backup archive | ||
+ | ** make submit | ||
+ | ** ** | ||
+ | ** make update | ||
+ | ** make reupdate | ||
+ | ** make reupdate-all | ||
+ | ** ** | ||
+ | ** make clean - clean; remove all objects/compiled code ** | ||
+ | ** make help - this information | ||
+ | ************************************************************************ | ||
+ | lab46: | ||
</ | </ | ||
- | And, of course, your basic compile and clean-up operations: | + | A description |
* **make**: compile everything | * **make**: compile everything | ||
+ | * any **warnings** or **errors** generated by the compiler will go into a file in the base directory of pnc0 in a file called **errors**; you can **cat** it to view the information. | ||
* **make debug**: compile everything with debug support | * **make debug**: compile everything with debug support | ||
+ | * any **warnings** or **errors** generated by the compiler will be displayed to the screen as the programs compile. | ||
* **make clean**: remove all binaries | * **make clean**: remove all binaries | ||
+ | * **make save**: make a backup of your current work | ||
+ | * **make submit**: archive and submit your project | ||
- | Just another | + | The various |
- | NOTE: You do NOT want to do this on a populated pnc2/ project | + | The various " |
+ | |||
+ | Just another "nice thing" we deserve. | ||
=====Command-Line Arguments===== | =====Command-Line Arguments===== | ||
- | To automate our comparisons, | + | To automate our comparisons, |
====header files==== | ====header files==== | ||
Line 215: | Line 292: | ||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||
</ | </ | ||
+ | |||
+ | There are two very important variables involved here (the types are actually what are important, the names given to the variables are actually quite, variable; you may see other references refer to them as things like " | ||
+ | |||
+ | * int argc: the count (an integer) of tokens given on the command line (program name + arguments) | ||
+ | * < | ||
The arguments are accessible via the argv array, in the order they were specified: | The arguments are accessible via the argv array, in the order they were specified: | ||
- | | + | * argv[0]: program invocation (path + program name) |
- | | + | * argv[1]: our maximum / upper bound |
+ | * argv[2]: reserved value, should still be provided and be a 1 for this project | ||
+ | * argv[3]: conditionally optional; represents lower bound | ||
+ | * argv[4]: conditionally optional; represents upper bound | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | ===example=== | ||
+ | For example, if we were to execute the **primeregbms** program: | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | We'd have: | ||
+ | |||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | |||
+ | and let's not forget: | ||
+ | |||
+ | * argc: 5 | ||
+ | |||
+ | With the conditionally optional arguments as part of the program spec, for a valid execution of the program, argc could be a value anywhere from 3 to 5. | ||
====Simple argument checks==== | ====Simple argument checks==== | ||
- | Although I'm not going to require extensive argument parsing or checking for this project, | + | While there are a number of checks |
<code c> | <code c> | ||
- | if (argc < 2) // if less than 2 arguments have been provided | + | if (argc < 3) // if less than 3 arguments |
{ | { | ||
- | fprintf(stderr, | + | fprintf(stderr, |
exit(1); | exit(1); | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Since argv[3] (lower bound) and argv[4] (upper bound) are conditionally optional, it wouldn' | ||
====Grab and convert max==== | ====Grab and convert max==== | ||
- | Finally, we need to put the argument representing the maximum | + | Finally, we need to put the argument representing the maximum |
I'd recommend declaring a variable of type **int**. | I'd recommend declaring a variable of type **int**. | ||
Line 240: | Line 350: | ||
<code c> | <code c> | ||
- | max = atoi(argv[1]); | + | max = atoi (argv[1]); |
</ | </ | ||
Line 456: | Line 566: | ||
====Displaying the runtime==== | ====Displaying the runtime==== | ||
- | Once we having | + | Once we have the starting and ending times, we can display this to the **timing** file pointer. You'll want this line: |
<code c> | <code c> | ||
- | | + | fprintf(timing, " |
+ | time_end.tv_sec-time_start.tv_sec+((time_end.tv_usec-time_start.tv_usec)/ | ||
</ | </ | ||
- | For clarity sake, that format specifier is " | + | For clarity sake, that format specifier is " |
And with that, we can compute an approximate run-time of our programs. The timing won't necessarily be accurate down to that level of precision, but it will be informative enough for our purposes. | And with that, we can compute an approximate run-time of our programs. The timing won't necessarily be accurate down to that level of precision, but it will be informative enough for our purposes. | ||
Line 497: | Line 608: | ||
And of course the same for the 3 variants, and the same error message reporting if invalid values are given. | And of course the same for the 3 variants, and the same error message reporting if invalid values are given. | ||
+ | |||
====Performance changes==== | ====Performance changes==== | ||
You may notice a change with the sieves as compared to the other algorithms you've implemented with respect to performance- there will likely be a lower bound of performance, | You may notice a change with the sieves as compared to the other algorithms you've implemented with respect to performance- there will likely be a lower bound of performance, | ||
=====Check Results===== | =====Check Results===== | ||
- | To verify your program's correctness and view your implementation' | + | If you'd like to compare |
- | I'll hold off from posting actual primerun output; I want you to see the results without any expectations. Do know that the arrangement of programs (from left to right) is in order of worst to best performance based on my implementations. | + | In order to work, you **MUST** be in the directory where your pnc2 binaries reside, and must be named as such (which occurs if you ran **make** to compile them). |
- | + | ||
- | If/when the runtime of a particular prime variant exceeds an upper threshold (likely to be set at 2 seconds), it will be omitted from further tests, and a series of dashes will instead appear in the output. | + | |
- | + | ||
- | If you don't feel like waiting, simply hit **CTRL-c** and the script will terminate. | + | |
- | + | ||
- | If the check is successful, you will see " | + | |
- | + | ||
- | =====Submission===== | + | |
- | To successfully complete this project, the following criteria must be met: | + | |
- | + | ||
- | * Code must compile cleanly (no warnings or errors) | + | |
- | * Output must be correct, and match the form given in the sample output above. | + | |
- | * Code must be nicely and consistently indented | + | |
- | * Code must utilize the algorithm(s) presented above. | + | |
- | * **primesoe.c** | + | |
- | * **primesoeodd.c** | + | |
- | * **primesoesrt.c** | + | |
- | * **primesoesrtodd.c** | + | |
- | * Code must be commented | + | |
- | * have a properly filled-out comment banner at the top | + | |
- | * be sure to include any compiling instructions | + | |
- | * have at least 20% of your program consist of **< | + | |
- | * Output Formatting (including spacing) of program must conform to the provided output (see above). | + | |
- | * Track/ | + | |
- | * Submit a copy of your source code to me using the **submit** tool. | + | |
- | + | ||
- | To submit this program to me using the **submit** tool, run the following command at your lab46 prompt: | + | |
+ | ====check qty==== | ||
<cli> | <cli> | ||
- | $ submit cprog pnc2 primesoe.c primesoeodd.c primesoesrt.c primesoesrtodd.c | + | lab46:~/src/discrete/pnc2$ make checkqty |
- | Submitting cprog project " | + | ========================================================= |
- | -> primesoe.c(OK) | + | |
- | -> primesoeodd.c(OK) | + | ========================================================= |
- | -> primesoesrt.c(OK) | + | |
- | -> primesoesrtodd.c(OK) | + | 64 0.0002 |
- | + | | |
- | SUCCESSFULLY SUBMITTED | + | |
- | </cli> | + | |
- | + | 1024 0.0006 | |
- | You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | + | 2048 0.0011 |
- | + | | |
- | What I will be looking for: | + | |
- | + | 16384 0.0088 | |
- | < | + | |
- | 78: | + | |
- | *: | + | |
- | *:pnc2:primesoe.c no negative compiler messages [2/2] | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | </ | + | |
- | + | ||
- | <WRAP centeralign round box> | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | + | ||
- | ~~TOC~~ | + | |
- | + | ||
- | ======Project: ALGORITHMS - PRIME NUMBER CALCULATION (pnc1)====== | + | |
- | + | ||
- | + | ||
- | =====Background===== | + | |
- | In mathematics, | + | |
- | + | ||
- | The number **6** is a **composite** number, as in addition to 1 and 6, it also has the factors of 2 and 3. | + | |
- | + | ||
- | The number **17**, however, is a **prime** number, as no numbers other than 1 and 17 can be evenly divided into it. | + | |
- | + | ||
- | =====Calculating the primality of a number===== | + | |
- | As of yet, there is no quick and direct way of determining the primality of a given number. Instead, we must perform a series of tests to determine if it fails primality (typically by proving it is composite). | + | |
- | + | ||
- | This process incurs a considerable amount of processing overhead on the task, so much so that increasingly large values take ever-expanding amounts of time. Often, approaches to prime number calculation involve various algorithms, which offer various benefits (less time) and drawback (more complex code). | + | |
- | + | ||
- | Your task for this project is to implement a prime number program using the straightforward, | + | |
- | + | ||
- | =====Review of main algorithm: brute force (primereg)===== | + | |
- | The brute force approach is the simplest to implement, although it does come at some cost, which hopefully you have realized by now having completed **pnc0**. | + | |
- | + | ||
- | To review the process of computing the primality of a number, we simply attempt to evenly divide all the potential factors between 2 and one less than the number into the number in question. If any one of them divides evenly, the number is **NOT** prime, but instead classified as composite (meaning made up of various parts, in this case those " | + | |
- | + | ||
- | Checking the **remainder** of an integer division indicates whether or not a division was clean (having 0 remainder indicates such a state). | + | |
- | + | ||
- | For example, with the number 11: | + | |
- | + | ||
- | < | + | |
- | 11 % 2 = 1 (2 is not a factor of 11) | + | |
- | 11 % 3 = 2 (3 is not a factor of 11) | + | |
- | 11 % 4 = 3 (4 is not a factor of 11) | + | |
- | 11 % 5 = 1 (5 is not a factor of 11) | + | |
- | 11 % 6 = 5 (6 is not a factor of 11) | + | |
- | 11 % 7 = 4 (7 is not a factor of 11) | + | |
- | 11 % 8 = 3 (8 is not a factor of 11) | + | |
- | 11 % 9 = 2 (9 is not a factor of 11) | + | |
- | 11 % 10 = 1 (10 is not a factor of 11) | + | |
- | </ | + | |
- | + | ||
- | Because none of the values 2-10 evenly divided into 11, we can say it passed the test: **11 is a prime number** | + | |
- | + | ||
- | On the other hand, take 119: | + | |
- | + | ||
- | < | + | |
- | 119 % 2 = 1 (2 is not a factor of 119) | + | |
- | 119 % 3 = 2 (3 is not a factor of 119) | + | |
- | 119 % 4 = 3 (4 is not a factor of 119) | + | |
- | 119 % 5 = 4 (5 is not a factor of 119) | + | |
- | 119 % 6 = 5 (6 is not a factor of 119) | + | |
- | 119 % 7 = 0 (7 is a factor of 119) | + | |
- | 119 % 8 = 7 | + | |
- | 119 % 9 = 2 | + | |
- | 119 % 10 = 9 | + | |
- | 119 % 11 = 9 | + | |
- | 119 % 12 = 11 | + | |
- | 119 % 13 = 2 | + | |
... | ... | ||
- | </ | + | 2097152 |
- | + | ========================================================= | |
- | Because, during our range of testing every value from 2-118, we find that 7 evenly divides into 119, it failed the test: 119 is **not** prime, but is instead a composite number. | + | verify: OK OK OK OK OK OK |
- | + | ========================================================= | |
- | ====algorithm==== | + | lab46: |
- | Some things to keep in mind on your implementation: | + | |
- | + | ||
- | * you will want to use loops (no less than 2, no more than 2) for this program. | + | |
- | * a nested loop makes the most sense: | + | |
- | * an outer loop that drives the progression of each sequential number to be tested | + | |
- | * an inner loop that tests that current number to see if it has any factors | + | |
- | * you know the starting value and the terminating condition, so you have a clear starting and ending point to work with. | + | |
- | * I want you to use two **DIFFERENT** kind of loops in your programs. If you use a **for()** loop in your outer loop, I want you to use a **while()** or **do-while()** loop in your inner loop (and whatever combination you end up with). | + | |
- | * I do **NOT** want to see ambiguous, one-letter variables used in your implementation(s). Please use // | + | |
- | * Some good examples of variable names would be: | + | |
- | * **number**: the number being tested | + | |
- | * **factor**: the value being divided into number to test for primality | + | |
- | * **step**: the rate by which some variable is changing | + | |
- | * **qty**: the count of the current tally of primes | + | |
- | * **max**: the maximum count we seek | + | |
- | * **start**: a value we are starting at | + | |
- | * **lower**: a lower bound | + | |
- | * **upper**: an upper bound | + | |
- | * see how much more readable and meaningful these are, especially as compared to **a**, **i**, **n**, **x**? You may even find it helps with debugging and understanding your code better. | + | |
- | * let the loops drive the overall process. Identify prime/ | + | |
- | * be mindful of the particular combination of optimizations you are implementing. | + | |
- | * your timing should start before the loop (just AFTER argument processing), | + | |
- | + | ||
- | =====prime algorithm optimizations===== | + | |
- | To give us a decent appreciation of the subtleties of algorithm development in a theme of programs, I have identified the following optimizations that we will be implementing. | + | |
- | + | ||
- | For simplicity, I have encoded this information in the file name (and therefore resulting executable/ | + | |
- | + | ||
- | To break it down, all prime programs will be of the form: | + | |
- | * primeALG[O...] | + | |
- | * where each and every program starts with " | + | |
- | * is immediately followed by a 3-letter (lowercase) abbreviation of the algorithm to be implemented (**reg**, for instance) | + | |
- | * and then is followed by 0 or more layered attributes describing the particular optimization that is applied (again, if any: **zero** or more). | + | |
- | + | ||
- | The optimizations we will be implementing in this project (and their naming values) include: | + | |
- | * **break on composite (b)** - once a tested number is proven composite, there is no need to continue processing: break out of the factor loop and proceed to the next number | + | |
- | * **mapping factors of 6 (m)** - it turns out that, aside from the initial primes of **2** and **3**, that **all** prime numbers fall to a +1 or -1 off a factor of six (there is an algorithm for this: **6a+/-1**). This optimization will utilize this property, only testing numbers +/-1 off of factors of 6 (how might this impact overall processing? | + | |
- | * **odds-only checking (o)** - aside from **2**, **all** other prime numbers are odd. Therefore, there is zero need to perform a composite check on an even number, allowing us to focus exclusively on odd values (luckily, they seem to occur in a predictable pattern). | + | |
- | * **sqrt() trick (s)** - mathematically it has been shown that if a number has any evenly divisible factors, at least one half of that factor pair will occur by the square root point of the number being tested. | + | |
- | * **sqrt()-less square root approximation (a)** - **sqrt()**, a function in the math library, does an industrial strength square root calculation. We don't need that, merely a whole integer value corresponding to the approximate square root. Here we will implement our own logic to approximate square root, hopefully with a considerable performance impact. | + | |
- | + | ||
- | Unless specified in the encoded name, your algorithm should only implement the algorithm and optimization(s) specified. | + | |
- | + | ||
- | That is, if your program to implement is **primerego**, | + | |
- | + | ||
- | On the other hand, if your program to implement is **primeregbms**, | + | |
- | + | ||
- | Some of these optimizations can co-exist easily (break + map, odd + sqrt()), others are partially compatible (map + odd can coexist in a certain form), while others are mutually exclusive (sqrt() and approximated square root conflict). So there are definitely a few combinations that are possible using this scheme. | + | |
- | + | ||
- | For this project, you'll be implementing the remaining (14) combinations of optimizations, | + | |
- | + | ||
- | =====Programs===== | + | |
- | + | ||
- | Those variants to implement are: | + | |
- | * the remainder of the viable double optimization combinations: | + | |
- | * **primeregmo.c**: | + | |
- | * **primeregms.c**: | + | |
- | * **primeregma.c**: | + | |
- | * **primeregos.c**: | + | |
- | * **primeregoa.c**: | + | |
- | * all of the viable triple optimization combinations: | + | |
- | * **primeregbmo.c**: | + | |
- | * **primeregbms.c**: | + | |
- | * **primeregbma.c**: | + | |
- | * **primeregbos.c**: | + | |
- | * **primeregboa.c**: | + | |
- | * **primeregmos.c**: | + | |
- | * **primeregmoa.c**: | + | |
- | * all of the viable quadruple optimizations combinations: | + | |
- | * **primeregbmos.c**: | + | |
- | * **primeregbmoa.c**: | + | |
- | + | ||
- | You should, if you haven' | + | |
- | + | ||
- | ====Program Specifications==== | + | |
- | Your program should: | + | |
- | * obtain 2-4 parameters from the command-line (see **command-line arguments** section below). | + | |
- | * check to make sure the user indeed supplied enough parameters, and exit with an error message if not. | + | |
- | * argv[1]: maximum quantity of primes to calculate (your program should run until it discovers **that** many primes). | + | |
- | * this value should be an integer value, greater than or equal to 0. | + | |
- | * if argv[1] is 0, disable the quantity check, and rely on provided lower and upper bounds (up to argv[4] would be required in this case). | + | |
- | * argv[2]: reserved for future compatibility; | + | |
- | * argv[3]: **conditionally optional** lower bound (starting value). Most of the time, this will probably be **2**, but should be a positive integer greater than or equal to 2. This defines where your program will start its prime quantity check from. | + | |
- | * if omitted, assume a lower bound of **2**. | + | |
- | * if you desired to specify an upper bound (argv[4]), you obviously MUST provide the lower bound argument under this scheme. | + | |
- | * argv[4]: **conditionally optional** upper bound (ending value). If provided, this is the ending value you'd like to check to. | + | |
- | * If doing a quantity run (argv[1] is NOT 0), this value isn't necessary. | + | |
- | * If doing a quantity run AND you specify an upper bound, whichever condition is achieved first dictates program termination. That is, upper bound could override quantity (if it is achieved before quantity), and quantity can override the upper bound (if it is achieved before reaching the specified upper bound). | + | |
- | * for each argument: you should do a basic check to ensure the user complied with this specification, | + | |
- | * for insufficient quantity of arguments, display: **PROGRAM_NAME: | + | |
- | * for invalid argv[1], display: **PROGRAM_NAME: | + | |
- | * for invalid argv[2], display: **PROGRAM_NAME: | + | |
- | * for invalid argv[3], display: **PROGRAM_NAME: | + | |
- | * if argv[3] is not needed, ignore (no error displayed not forced exit, as it is acceptable defined behavior). | + | |
- | * for invalid argv[4], display: **PROGRAM_NAME: | + | |
- | * if argv[4] is not needed, ignore (no error displayed nor forced exit, as it is acceptable defined behavior). | + | |
- | * In these error messages, **PROGRAM_NAME** is the name of the program being run; this can be accessed as a string stored in **argv[0]**. | + | |
- | * implement ONLY the algorithm and optimization(s) specified in the program name. We are producing multiple data points for a broader performance comparison. | + | |
- | * please take note on differences in run-time, contemplating the impact the algorithm and optimization(s) have on performance (timing, specifically). | + | |
- | * immediately after argument processing: start your stopwatch (see **timing** section below). | + | |
- | * perform the correct algorithm and optimization(s) against the command-line input(s) given. | + | |
- | * each program is to have no fewer and no more than 2 loops in this prime processing section. | + | |
- | * in each program, you are not allowed to use a given loop type (for(), while(), do-while()) more than once! | + | |
- | * utilize meaningful variable names (I do not want to see things like **a**, **i**, **n**, **x** being used which have no meaningful bearing on the role they serve). | + | |
- | * display identified primes (space-separated) to a file pointer called **primelist** | + | |
- | * stop your stopwatch immediately following your prime processing loops (and terminating newline display to **primelist**). Calculate the time that has transpired (ending time minus starting time). | + | |
- | * output the processing run-time to the file pointer called **timing** | + | |
- | * your output **MUST** conform to the example output in the **execution** section below. This is also a test to see how well you can implement to specifications. Basically: | + | |
- | * as primes are being displayed, they are space-separated (first prime hugs the left margin), and when all said and done, a newline is issued. | + | |
- | * the timing information will be displayed in accordance to code I will provide below (see the **timing** section). | + | |
- | + | ||
- | =====Grabit Integration===== | + | |
- | For those familiar with the **grabit** tool on lab46, I have made some skeleton files and a custom **Makefile** available for this project. | + | |
- | + | ||
- | To " | + | |
- | + | ||
- | NOTE: You will **NEED** to specify the semester as indicated as the semester in question has not yet started. | + | |
- | + | ||
- | < | + | |
- | lab46: | + | |
- | make: Entering directory '/ | + | |
- | Commencing copy process for fall2017 discrete project pnc1: | + | |
- | -> Creating project pnc1 directory tree ... OK | + | |
- | -> Copying pnc1 project files ... OK | + | |
- | -> Synchronizing pnc1 project revision level ... OK | + | |
- | -> Establishing sane file permissions for pnc1 ... OK | + | |
- | + | ||
- | *** Copy COMPLETE! You may now go to the '/ | + | |
- | + | ||
- | make: Leaving directory '/ | + | |
- | lab46: | + | |
- | lab46: | + | |
- | lab46: | + | |
</ | </ | ||
- | NOTE: You do NOT want to do this on a populated pnc1 project directory-- | + | When the runtime of a particular prime variant exceeds an upper threshold (1 second), |
- | And, of course, your basic compile and clean-up operations via the Makefile. | + | If you don' |
- | + | ||
- | =====Makefile operations===== | + | |
- | Makefiles provide a build automation system for our programs, instructing the computer on how to compile files, so we don' | + | |
- | + | ||
- | Basic operation of the Makefile is invoked by running the command "**make**" by itself. The default action is to compile everything in the project directory. | + | |
- | + | ||
- | Additional options are available, | + | |
+ | ====check range==== | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | ******************[ Discrete Structures pnc1 Project ]****************** | + | coming soon |
- | ** make - build everything | + | lab46: |
- | ** make showerrors | + | |
- | ** ** | + | |
- | ** make debug - build everything with debug symbols | + | |
- | ** make check - check implementation for validity | + | |
- | ** ** | + | |
- | ** make link - link in previous prime programs | + | |
- | ** make delink | + | |
- | ** ** | + | |
- | ** make save - create a backup archive | + | |
- | ** make submit | + | |
- | ** ** | + | |
- | ** make update | + | |
- | ** make reupdate | + | |
- | ** make reupdate-all | + | |
- | ** ** | + | |
- | ** make clean - clean; remove all objects/ | + | |
- | ** make help - this information | + | |
- | ************************************************************************ | + | |
- | lab46: | + | |
</ | </ | ||
- | A description of some available commands include: | + | ====Verification==== |
- | + | I also include a validation | |
- | * **make**: compile everything | + | |
- | * any **warnings** or **errors** generated by the compiler will go into a file in the base directory of the project in a file called **errors**; you can **cat** it to view the information. | + | |
- | * **make debug**: compile everything with debug support | + | |
- | * any **warnings** or **errors** generated by the compiler will be displayed to the screen as the programs compile. | + | |
- | * **make clean**: remove all binaries | + | |
- | * **make save**: make a backup of your current work | + | |
- | * **make submit**: archive and submit your project | + | |
- | + | ||
- | Just another "nice thing" we deserve. | + | |
- | + | ||
- | =====Command-Line Arguments===== | + | |
- | To automate our comparisons, | + | |
- | + | ||
- | ====header files==== | + | |
- | We don't need any extra header files to use command-line arguments, but we will need an additional header file to use the **atoi(3)** function, which we'll use to quickly turn the command-line parameter into an integer, and that header file is **stdlib.h**, | + | |
- | + | ||
- | <code c> | + | |
- | #include < | + | |
- | #include < | + | |
- | </ | + | |
- | + | ||
- | ====setting up main()==== | + | |
- | To accept (or rather, to gain access) to arguments given to your program at runtime, we need to specify two parameters to the main() function. While the names don't matter, the types do.. I like the traditional **argc** and **argv** names, although it is also common to see them abbreviated as **ac** and **av**. | + | |
- | + | ||
- | Please declare your main() function as follows: | + | |
- | + | ||
- | <code c> | + | |
- | int main(int argc, char **argv) | + | |
- | </ | + | |
- | + | ||
- | The arguments are accessible via the argv array, in the order they were specified: | + | |
- | + | ||
- | * argv[0]: program invocation (path + program name) | + | |
- | * argv[1]: our maximum / upper bound | + | |
- | * argv[2]: reserved value, should still be provided and be a 1 for this project | + | |
- | * argv[3]: conditionally optional; represents lower bound | + | |
- | * argv[4]: conditionally optional; represents upper bound | + | |
- | + | ||
- | ====Simple argument checks==== | + | |
- | While there are a number of checks we should perform, one of the first should be a check to see if the minimal number of arguments has been provided: | + | |
- | + | ||
- | <code c> | + | |
- | if (argc < 3) // if less than 3 arguments (program_name + quantity + argv[2] == 3) have been provided | + | |
- | { | + | |
- | fprintf(stderr, | + | |
- | exit(1); | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Since argv[3] (lower bound) and argv[4] (upper bound) | + | |
- | + | ||
- | ====Grab and convert max==== | + | |
- | Finally, we need to put the argument representing the maximum quantity into a variable. | + | |
- | + | ||
- | I'd recommend declaring a variable of type **int**. | + | |
- | + | ||
- | We will use the **atoi(3)** function to quickly convert the command-line arguments into **int** values: | + | |
- | + | ||
- | <code c> | + | |
- | max = atoi (argv[1]); | + | |
- | </ | + | |
- | + | ||
- | And now we can proceed with the rest of our prime implementation. | + | |
- | + | ||
- | =====Timing===== | + | |
- | Often times, when checking | + | |
- | + | ||
- | In order to do that in our prime number programs, we are going to use C library functions that obtain the current time, and use it as a stopwatch: we'll grab the time just before starting processing, and then once more when done. The total time will then be the difference between the two (end_time - start_time). | + | |
- | + | ||
- | We are going to use the **gettimeofday(2)** function to aid us in this, and to use it, we'll need to do the following: | + | |
- | + | ||
- | ====header file==== | + | |
- | In order to use the **gettimeofday(2)** function in our program, we'll need to include the **sys/ | + | |
- | + | ||
- | <code c> | + | |
- | #include < | + | |
- | #include < | + | |
- | #include < | + | |
- | </ | + | |
- | + | ||
- | ====timeval variables==== | + | |
- | **gettimeofday(2)** uses a **struct timeval** data type, of which we'll need to declare two variables in our programs (one for storing the starting time, and the other for the ending time). | + | |
- | + | ||
- | Please declare these with your other variables, up at the top of main() (but still WITHIN main()-- you do not need to declare global variables). | + | |
- | + | ||
- | <code c> | + | |
- | struct timeval time_start; // starting time | + | |
- | struct timeval time_end; | + | |
- | </ | + | |
- | + | ||
- | ====Obtaining the time==== | + | |
- | To use **gettimeofday(2)**, | + | |
- | + | ||
- | For our prime number programs, you'll want to grab the start time **AFTER** you've declared variables and processed arguments, but **JUST BEFORE** starting the driving loop doing the processing. | + | |
- | + | ||
- | That call will look something like this: | + | |
- | + | ||
- | <code c> | + | |
- | gettimeofday(& | + | |
- | </ | + | |
- | + | ||
- | The ending time should be taken immediately after all processing (and prime number output) is completed, and right before we display the timing information to STDERR: | + | |
- | + | ||
- | <code c> | + | |
- | gettimeofday(& | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | =====Execution===== | + | |
- | ====specified quantity==== | + | ====Full Verification Compliance==== |
- | Your program output should be as follows (given the specified quantity): | + | There' |
<cli> | <cli> | ||
- | lab46: | + | lab46: |
- | 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 | + | coming soon |
- | | + | lab46: |
- | lab46: | + | |
</ | </ | ||
- | The execution of the programs | + | ===verifyall tests=== |
+ | The " | ||
+ | * **qtynorm**: | ||
+ | * **./ | ||
+ | * **qtypart**: | ||
+ | * **./ | ||
+ | * **rngnorm**: | ||
+ | * **./ | ||
+ | * **rngpart**: | ||
+ | * **./ | ||
+ | * **coop**: both qty and upper bounds set (q: 2048, ub: 8192) | ||
+ | * **./ | ||
+ | * **coop2**: both qty and upper bounds set (q: 512, ub: 8192) | ||
+ | * **./ | ||
+ | * **coop3**: both qty and upper bounds set, offset start (24-max, q: 2048, ub: 8192) | ||
+ | * **./ | ||
+ | * **noargs**: | ||
+ | * **./ | ||
+ | * **invargs**: | ||
+ | * **./ | ||
+ | * **invqty**: invalid value for quantity argument given (invokes error) | ||
+ | * **./ | ||
+ | * **invnary**: | ||
+ | * **./ | ||
+ | * **invlow**: invalid value given for lower bound (invokes error) | ||
+ | * **./ | ||
+ | * **invhigh**: | ||
+ | * **./primealg 128 1 32 24** | ||
- | ====invalid lower bound==== | + | If you'd actually to see the output your program' |
- | Here' | + | |
- | < | + | For example, if you wanted to see the intended output of the **invnary** test, that would be found in: |
- | lab46:~/ | + | |
- | ./ | + | |
- | lab46: | + | |
- | </ | + | |
- | In this case, the program logic should have detected an invalid condition and bailed out before prime computations even began. No timing data is displayed, because exiting should occur even prior to that. | + | * **/ |
- | ====upper bound overriding quantity==== | + | You could easily run your program |
- | As indicated above, there is potential interplay | + | |
- | + | ||
- | < | + | |
- | lab46: | + | |
- | 7 11 13 17 19 23 | + | |
- | 0.0001 | + | |
- | lab46: | + | |
- | </ | + | |
- | + | ||
- | Also for fun, I set the lower bound to 7, so you'll see computation starts at 7 (vs. the usual 2). | + | |
- | + | ||
- | =====Check Results===== | + | |
- | If you'd like to compare your implementations, | + | |
- | + | ||
- | In order to work, you **MUST** be in the directory where your pnc1 binaries reside, | + | |
- | + | ||
- | For instance (running on my implementation of the pnc1 programs, some output omitted to keep the surprise alive): | + | |
- | + | ||
- | < | + | |
- | lab46: | + | |
- | ========================================================================================================================= | + | |
- | qty | + | |
- | ========================================================================================================================= | + | |
- | | + | |
- | | + | |
- | 128 0.0005 | + | |
- | 256 0.0021 | + | |
- | 512 0.0096 | + | |
- | | + | |
- | ... | + | |
- | | + | |
- | ========================================================================================================================= | + | |
- | | + | |
- | ========================================================================================================================= | + | |
- | lab46: | + | |
- | </ | + | |
- | + | ||
- | If the runtime of a particular prime variant exceeds an upper runtime threshold (likely to be set at 1 second), it will be omitted from further tests, and a series of dashes will instead appear in the output. | + | |
- | + | ||
- | If you don't feel like waiting, simply hit **CTRL-c** (maybe a couple of times) and the script will terminate. | + | |
- | + | ||
- | I also include a validation check- to ensure your prime programs are actually producing the correct list of prime numbers. If the check is successful, you will see " | + | |
+ | ====In general==== | ||
Analyze the times you see... do they make sense, especially when comparing the algorithm used and the quantity being processed? These are related to some very important core Computer Science considerations we need to be increasingly mindful of as we design our programs and implement our solutions. Algorithmic complexity and algorithmic efficiency will be common themes in all we do. | Analyze the times you see... do they make sense, especially when comparing the algorithm used and the quantity being processed? These are related to some very important core Computer Science considerations we need to be increasingly mindful of as we design our programs and implement our solutions. Algorithmic complexity and algorithmic efficiency will be common themes in all we do. | ||
Line 999: | Line 711: | ||
* Code must be nicely and consistently indented (you may use the **indent** tool) | * Code must be nicely and consistently indented (you may use the **indent** tool) | ||
* Code must utilize the algorithm(s) presented above: | * Code must utilize the algorithm(s) presented above: | ||
- | | + | * soe |
- | * **primeregms.c**: | + | * **primesoe.c**: baseline sieve of eratosthenes |
- | * **primeregma.c**: | + | * **primesoeo.c**: odd traversal |
- | * **primeregos.c**: | + | * **primesoes.c**: sqrt() trick |
- | * **primeregoa.c**: odd traversal + approximated square root trick | + | * **primesoea.c**: approximated square root |
- | * **primeregbmo.c**: break + map + odd traversal | + | * **primesoeos.c**: odd traversal + sqrt() trick |
- | * **primeregbms.c**: break + map + sqrt() trick | + | * **primesoeoa.c**: odd traversal + approximated square root |
- | * **primeregbma.c**: break + map + approximated square root trick | + | * Code must be commented, and comments must focus on the how and why of the process. |
- | * **primeregbos.c**: break + odd + sqrt() trick | + | |
- | * **primeregboa.c**: | + | |
- | * **primeregmos.c**: | + | |
- | * **primeregmoa.c**: map + odd traversal + approximated square root trick | + | |
- | * **primeregbmos.c**: | + | |
- | * **primeregbmoa.c**: | + | |
- | * Code must be commented | + | |
- | * have a properly filled-out comment banner at the top | + | |
- | * be sure to include any compiling instructions | + | |
- | * have at least 20% of your program consist of **< | + | |
* Output Formatting (including spacing) of program must conform to the provided output (see above). | * Output Formatting (including spacing) of program must conform to the provided output (see above). | ||
* Track/ | * Track/ | ||
Line 1024: | Line 726: | ||
<cli> | <cli> | ||
- | lab46: | + | lab46: |
Delinking ... | Delinking ... | ||
- | removed ‘primerega.c’ | ||
- | removed ‘primeregba.c’ | ||
- | removed ‘primeregb.c’ | ||
- | removed ‘primeregbm.c’ | ||
- | removed ‘primeregbo.c’ | ||
- | removed ‘primeregbs.c’ | ||
- | removed ‘primereg.c’ | ||
- | removed ‘primeregm.c’ | ||
- | removed ‘primerego.c’ | ||
- | removed ‘primeregs.c’ | ||
- | removed ‘primeregbma’ | ||
- | removed ‘primeregbmoa’ | ||
- | removed ‘primeregbmo’ | ||
- | removed ‘primeregbmos’ | ||
- | removed ‘primeregbms’ | ||
- | removed ‘primeregboa’ | ||
- | removed ‘primeregbos’ | ||
- | removed ‘primeregma’ | ||
- | removed ‘primeregmoa’ | ||
- | removed ‘primeregmo’ | ||
- | removed ‘primeregmos’ | ||
- | removed ‘primeregms’ | ||
- | removed ‘primeregoa’ | ||
- | removed ‘primeregos’ | ||
removed ‘errors’ | removed ‘errors’ | ||
Project backup process commencing | Project backup process commencing | ||
- | Taking snapshot of current project (pnc1) ... OK | + | Taking snapshot of current project (pnc2) ... OK |
- | Compressing snapshot of pnc1 project archive | + | Compressing snapshot of pnc2 project archive |
- | Setting secure permissions on pnc1 archive | + | Setting secure permissions on pnc2 archive |
Project backup process complete | Project backup process complete | ||
- | Submitting discrete project "pnc1": | + | Submitting discrete project "pnc2": |
- | -> ../pnc1-20170713-11.tar.gz(OK) | + | -> ../pnc2-DATESTRING-HR.tar.gz(OK) |
SUCCESSFULLY SUBMITTED | SUCCESSFULLY SUBMITTED | ||
Line 1068: | Line 746: | ||
You should get that final " | You should get that final " | ||
- | What I will be looking for: | + | ====Evaluation Criteria==== |
+ | Grand total points: | ||
+ | |||
+ | < | ||
+ | 390: | ||
+ | </ | ||
+ | |||
+ | What I will be looking for (for each file): | ||
< | < | ||
- | 364: | + | *:pnc2:primeALGO.c compiles cleanly, |
- | *:pnc1:primeregbma.c performs proper argument checking [2/2] | + | *:pnc2:primeALGO.c implements only specified algorithm [8/8] |
- | *: | + | *:pnc2:primeALGO.c consistent indentation |
- | *: | + | *:pnc2:primeALGO.c relevant how and why comments |
- | *: | + | *:pnc2:primeALGO.c code conforms |
- | *:pnc1:primeregbma.c data and output conform to specifications [6/6] | + | *:pnc2:primeALGO.c implementation free from restrictions |
- | *: | + | *:pnc2:primeALGO |
- | *: | + | *:pnc2:primeALGO |
- | *: | + | *:pnc2:primeALGO |
- | *: | + | *:pnc2:primeALGO |
- | *:pnc1:primeregbmoa.c consistent indentation | + | |
- | *:pnc1:primeregbmoa.c data and output conform to specifications [6/6] | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *:pnc1:primeregbmo.c data and output conform | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *:pnc1:primeregbmos.c data and output conform to specifications | + | |
- | *:pnc1:primeregbmos.c make check runtime | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *:pnc1:primeregboa.c data and output conform to specifications [6/6] | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *:pnc1:primeregbos.c data and output conform to specifications [6/6] | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *:pnc1:primeregma.c data and output conform to specifications [6/6] | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
- | *: | + | |
</ | </ |