DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   Need HELP!!!!! (http://www.daniweb.com/forums/thread138213.html)

dummy programer Aug 2nd, 2008 3:25 pm
Need HELP!!!!!
 
I NEED HELP WITH THIS PROBLEM!!!! ANYONE!!!!


/*3. Write the function: double max_norm(double *v, int n) to compute
the maximum norm of vector v[] with n elements. The max norm of a vector is
computed by taking the maximum absolute value of its elements.
In prob3() compute x1[]=a[][]*x0[], call max_norm() to compute the max_norm
x1[]. In order to normalize (or convert it to a unit vector), divide each
element of x1[] by the norm. Print the normalized x1[] using %12.4e. Then
copy x1[] as x0[] (to perform updating) and repeat the process nine more times
. */
double a[5][5]={ 1.0, 0.2, 0.6, 0.3,-0.2,
0.2, 3.0,-0.1, 0.2, 0.7,
0.6,-0.1, 2.0, 0.7, 0.1,
0.3, 0.2, 0.7, 5.5, 0.2,
-0.2, 0.7, 0.1, 0.2, 4.5 };
double x1[5], x0[5]={0.1, -0.5, 0.1, 1.0, 0.9};

Aia Aug 2nd, 2008 3:53 pm
Re: Need HELP!!!!!
 
Exactly, where are you having problems with?
Be more specific and post relevant portion of code you have tried already and it is not working.

dummy programer Aug 2nd, 2008 4:02 pm
Re: Need HELP!!!!!
 
I'm completely lost....I don't understand how to write the first function then call on it???

ArkM Aug 2nd, 2008 4:07 pm
Re: Need HELP!!!!!
 
...then ask your teacher to divide your homework grade by 2 and send the second half to the author of the best answer...

dummy programer Aug 2nd, 2008 4:44 pm
Re: Need HELP!!!!!
 
/*3. Write the function: double max_norm(double *v, int n) to compute
the maximum norm of vector v[] with n elements. The max norm of a vector is
computed by taking the maximum absolute value of its elements.
In prob3() compute x1[]=a[][]*x0[], call max_norm() to compute the max_norm
x1[]. In order to normalize (or convert it to a unit vector), divide each
element of x1[] by the norm. Print the normalized x1[] using %12.4e. Then
copy x1[] as x0[] (to perform updating) and repeat the process nine more times. */
        double a[5][5]={ 1.0, 0.2, 0.6, 0.3,-0.2,
                        0.2, 3.0,-0.1, 0.2, 0.7,
                        0.6,-0.1, 2.0, 0.7, 0.1,
                        0.3, 0.2, 0.7, 5.5, 0.2,
                        -0.2, 0.7, 0.1, 0.2, 4.5 };
        double x1[5], x0[5]={0.1, -0.5, 0.1, 1.0, 0.9};
// ***Enter your statements
        int i, k;
        double dot;
        for(i=0; i<5; i++){
                for(k=0, dot=0.0; k<5; k++){
                        dot +=a[i][k] * x0[k];
                        x1[i]=dot;
                }
        }

        return;
}
double max_norm(double *v, int n)
{
// ***Enter your statements


return;
}


All times are GMT -4. The time now is 10:17 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC