Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main Driver File: #define INSTRUCTOR_FILE #ifdef INSTRUCTOR_FILE #include #include #include #include C2A4E2_StorageMap5D.h #define D_A 2 #define D_B 3 #define D_C 4 #define D_D 5 #define

image text in transcribed
Main Driver File:
#define INSTRUCTOR_FILE
#ifdef INSTRUCTOR_FILE
#include
#include
#include
#include "C2A4E2_StorageMap5D.h"
#define D_A 2
#define D_B 3
#define D_C 4
#define D_D 5
#define D_E 6
int main(void)
{
int ix0, ix1, ix2, ix3, ix4;
int foo[D_A][D_B][D_C][D_D][D_E];
double bar[D_A][D_B][D_C][D_D][D_E];
long big[D_E][D_D][D_C][D_B][D_A];
float deal[D_E][D_D][D_C][D_B][D_A];
// seed random # generator
srand((unsigned)time(NULL));
// store all values before testing any
for (ix0 = 0; ix0
for (ix1 = 0; ix1
for (ix2 = 0; ix2
for (ix3 = 0; ix3
for (ix4 = 0; ix4
{
foo[ix0][ix1][ix2][ix3][ix4] = rand();
bar[ix0][ix1][ix2][ix3][ix4] = rand() + rand() / 321.0;
}
for (ix0 = 0; ix0
for (ix1 = 0; ix1
for (ix2 = 0; ix2
for (ix3 = 0; ix3
for (ix4 = 0; ix4
{
big[ix0][ix1][ix2][ix3][ix4] = rand();
deal[ix0][ix1][ix2][ix3][ix4] = rand() + rand() / 123.0F;
}
// Test all stored values.
for (ix0 = 0; ix0
for (ix1 = 0; ix1
for (ix2 = 0; ix2
for (ix3 = 0; ix3
for (ix4 = 0; ix4
{
if (StorageMap5D((int *)foo, ix0, ix1, ix2, ix3, ix4,
D_B, D_C, D_D, D_E) != foo[ix0][ix1][ix2][ix3][ix4])
{
fprintf(stderr, "Error: foo[%d][%d][%d][%d][%d] ",
ix0, ix1, ix2, ix3, ix4);
return EXIT_FAILURE;
}
if (StorageMap5D((double *)bar, ix0, ix1, ix2, ix3, ix4,
D_B, D_C, D_D, D_E) != bar[ix0][ix1][ix2][ix3][ix4])
{
fprintf(stderr, "Error: bar[%d][%d][%d][%d][%d] ",
ix0, ix1, ix2, ix3, ix4);
return EXIT_FAILURE;
}
}
for (ix0 = 0; ix0
for (ix1 = 0; ix1
for (ix2 = 0; ix2
for (ix3 = 0; ix3
for (ix4 = 0; ix4
{
if (StorageMap5D((long *)big, ix0, ix1, ix2, ix3, ix4,
D_D, D_C, D_B, D_A) != big[ix0][ix1][ix2][ix3][ix4])
{
fprintf(stderr, "Error: big[%d][%d][%d][%d][%d] ",
ix0, ix1, ix2, ix3, ix4);
return EXIT_FAILURE;
}
if (StorageMap5D((float *)deal, ix0, ix1, ix2, ix3, ix4,
D_D, D_C, D_B, D_A) != deal[ix0][ix1][ix2][ix3][ix4])
{
fprintf(stderr, "Error: deal[%d][%d][%d][%d][%d] ",
ix0, ix1, ix2, ix3, ix4);
return EXIT_FAILURE;
}
}
--ix0;
--ix1;
--ix2;
--ix3;
--ix4;
if (StorageMap5D((long *)big, ix0 + 1 - 1, ix1 + 2 - 2, ix2 + 3 - 3,
ix3 + 4 - 4, ix4 + 5 - 5, D_D + 4 - 4, D_C + 3 - 3, D_B + 2 - 2,
D_A + 1 - 1) !=
big[ix0][ix1][ix2][ix3][ix4])
{
fprintf(stderr, "Error 2: big[%d][%d][%d][%d][%d] ",
ix0, ix1, ix2, ix3, ix4);
return EXIT_FAILURE;
}
printf("Assignment 4 Exercise 2: No errors detected! ");
return EXIT_SUCCESS;
}
#endif
what is s? All information was provided, any help is deeply appreciated. Thank you.
file C2A4E2(6 points - Program) Exclude any existing source code files that may already be in your IDE project and add a new one. code naming it C2A4E2_StorageMap5D.h. Also add instructor-supplied source C2A4E2_main-Driver.c. Do not write a main functions main aready exists in the instructor-supplied file and it will use the code you write. File C2A4E2 StorageMap50.h must contain a macro named StorageMap5D. StorageMap5D syntax (never actually prototype a mocro): StorageMap5D(ptr, idxe, idxi, idx2, idx3, idx4, dini, dim2, dim3, dim) Parameters: ptr - a pointer to the first element of a block of memory to be used as a 5-dimensional array idxe, idx1. idx2. idx3. idx4 - the indices of the desired element of the array dimi, dim2. dim3, dim - the rightmost 4 dimensions of the array (dime isn't needed) Synopsis: implements the storage map equation for a 5-dimensional array of arbitrary type having arbitrary dimension values. It may be used to access the elements of any existing 5-dimensional array of any type and sufficient size, or in the general case may be used to access any arbitrary block of memory of sufficient size as if it were a 5-dimensional array Value: the element specified by the macro's 2nd through oth arguments. Example: For an arbitrary array of any type originally declared as type test[SZ_A][sz_B][sz_c][sz_D][SZ_E); or any block of dynamic memory allocated by type "test - (type *)malloc((SZ_ASZ_B. sz_C. SZ_DSZ_E) sizeof(type)) the expression StorageMap5D((type ->test, 68, 73, 22, 58, 49, SZ_B, SZ_C, SZ_D, SZ_E) would access the following element of the array or the dynamically-allocated memory block. [68][73][22][58] [49] # you get any assignment checker errors/warnings regarding instructor-supplied file C2A4E2_main-Driver.c it is because there is a problem in your macro. Submitting your solution Send both source code files to the assignment checker with the subject line C2A4E2_ID, where ID is your 9-character UCSD student ID See the course document titled "How to Prepare and Submit Assignments for additional exercise formatting. submission, and assignment checker requirements Hints: A typical procedure for testing any storage map equation is to first declare a standard array having the same type and dimension sizes as the storage map equation and store a different value in each element, then point the storage map equation to that array and verify that it accesses the expected values. That is what the instructor supplied source code file for this exercise does

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

explain what is meant by experiential learning

Answered: 1 week ago