Question: A weather radar system's embedded analysis logic has been written in C. This system runs continuously to search for anomolous weather patterns. The following
A weather radar system's embedded analysis logic has been written in C. This system runs continuously to search for anomolous weather patterns. The following is a snippet of linear algebra code used in its analysis: struct Vector { float x; float y; float z; }; struct Vector* cross_product(struct Vector* a, struct Vector* b) { struct Vector* r = (struct Vector*) malloc(sizeof(struct Vector)); r->x = a->y*b->z - a->z*b->y; r->y = a->z*b->x a->x*b->z; r->z = a->x*b->y - a->y*b->x; return r; } float magnitude (struct Vector* v) { return sqrt (v->x*v->x + v->y*v->y + v->z*v->z); } float cross_magnitude (struct Vector* a, struct Vector* b) { return magnitude (cross_product (a,b)); } The cross_magntiude() function is used routinely to estimate the size of storm patterns. Unfortunately, the system keeps mysteriously crashing every few days like clockwork, after which it is rebooted and works fine again until the next crash. The mathematical analysts have gone over the code repeatedly -- the math is perfect. How large, in bytes, is a Vector structure? What is wrong with this code, and why is it likely causing crashes every few days?
Step by Step Solution
3.49 Rating (156 Votes )
There are 3 Steps involved in it
The Vector structure appears to have three float variables x y and z In C the size of a ... View full answer
Get step-by-step solutions from verified subject matter experts
