Introduce SCXX in Exercise 10.11. Modify the script from Exercise 10.10 to take advantage of the…

Introduce SCXX in Exercise 10.11.

Modify the script from Exercise 10.10 to take advantage of
the SCXX library for simplified programming with the Python C API.

Exercise 10.11

Introduce C++ array objects in Exercise 10.10.

Add an option to the script developed in Exercise 10.10 such
that NumPy arrays can be wrapped in NumPyArray_Float objects from Chapter
10.3.1 to simplify programming.

Exercise 10.10

Almost automatic generation of C extension modules.

To simplify writing of C/C++ extension modules processing
NumPy arrays, we could let a script generate much of the source code. The
»

Introduce SCXX in Exercise 10.11.

Modify the script from Exercise 10.10 to take advantage of
the SCXX library for simplified programming with the Python C API.

Exercise 10.11

Introduce C++ array objects in Exercise 10.10.

Add an option to the script developed in Exercise 10.10 such
that NumPy arrays can be wrapped in NumPyArray_Float objects from Chapter
10.3.1 to simplify programming.

Exercise 10.10

Almost automatic generation of C extension modules.

To simplify writing of C/C++ extension modules processing
NumPy arrays, we could let a script generate much of the source code. The
template from Chapter 10.2.9 is a good starting point for dumping code. Let the
code generation script read a specification of the functions in the module. A
suggested syntax for specifying a function may look like

fname; i:NumPy(dim1,dim2) v1; io:NumPy(dim1) v2; o:float v3;
code

Such a line consists of fields separated by semi-colon. The
first field, fname, is the name of the function. The next fields are the input
and output arguments, where i: means input, o: output, and io: input and
output. The variable type appears after the input/output prefix: NumPy for
NumPy arrays, int for integer, float for floating-point numbers (double in C),
str for strings (char* arrays in C), and func for callbacks. After the type
specification we list the name of the variable. NumPy arrays have their
dimensions enclosed in parenthesis, e.g., v1 has associated C integers called
dim1 and dim2 for holding its dimensions. The last field is the name of a file
containing some core code of the function to be inserted before the return
statement. If code is simply the word none, no such user-provided code exists.

Arguments specified as o: are returned, the others are taken
as positional arguments in the same order as specified. Return None if there
are no output arguments.

For each callback function the script should generate a
skeleton with key statements in the callback, but the user is supposed to
manually specify the argument list and process the result.

Consistency checks of actual array dimensions and those
specified in the parenthesis proceeding NumPy must be generated.

For each function the script should generate a doc string
with the call syntax as seen from Python. This string should also be a part of
the module doc string.

As an example, the gridloop2 function can be specified as

gridloop2; i:NumPy(nx) xcoor; i:NumPy(ny) ycoor; i:func
func1; o:NumPy(nx,ny) a; gridloop2.c

(Everything is supposed to be on a single line. The line was
broken here because of page width limitations.) The file gridloop2.c is
supposed to contain the loop over the grid points, perhaps without the callback
details. Since these details to some extent will be generated by the script,
the user can move that code inside the loop and fill in the missing details.

The syntax of the function specifications is constructed
such that a simple split with respect to semi-colon extracts the fields, a
split with respect to white space distinguishes the type information from the
variable name, and a split with respect to colon of the type information
extracts the input/output specification. Extraction of array dimensions can be
done by splitting the appropriate substring ([6:-1]) with respect to comma.

»

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more