00001 #include "cammva.h"
00002 #include "mvagph.h"
00003 #include <iostream.h>
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <math.h>
00007 
00008 double f(double x,double y)
00009 {
00010 return (3*(1-x)*(1-x)*(exp(-x*x - (y+1)*(y+1)))
00011           -10*(x/5 - x*x*x - y*y*y*y*y)*(exp(-x*x - y*y))
00012           -(1/3.0)*(exp(-(x+1)*(x+1) - y*y)));
00013 
00014 };
00015 
00016 int main()
00017 {
00018 
00019         long N = 5;
00020         CAMdoubleVector B(N);
00021     CAMdoubleVector X(N);
00022 
00023     CAMmvaGraphics      Mgraphics;            
00024         CAMpostScriptDriver PSdriver("graph.ps"); 
00025         Mgraphics.attachDriver(PSdriver);         
00026 
00027 
00028 
00029    long i;  long j;
00030    for(i=1; i<=N; i++)
00031    {
00032     B(i)=double(i);
00033     X(i)=double(i)*.25;
00034    }
00035    B(3) = -1;
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054    long m; long n;
00055 
00056    m = 10;
00057    n = 40;
00058    CAMdoubleArray A(m,n);
00059    CAMdoubleArray XP(n);
00060    for(i= 1; i <= m; i++)
00061    {
00062    for(j = 1; j <=n; j++)
00063    {
00064      A(i,j) = cos(double(i)*3.14159*2.0*double(j-1)*(1.0)/double(n-1));
00065    }}
00066 
00067    for(j = 1; j <= n; j++)
00068    {
00069      XP(j) = double(j-1)/double(n-1);
00070    }
00071 
00072    
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088     m = 30;
00089     n = 30;
00090 
00091     CAMdoubleMatrix C(m,n);
00092 
00093     double a  = -3.0;                     
00094     double b  =  3.0;
00095     double c  = -3.0;
00096     double d =   3.0;
00097 
00098 
00099     double hx  = (b-a)/double(m-1);
00100     double hy  = (d-c)/double(n-1);
00101 
00102     for(i =1; i <= m; i++)
00103     {
00104     for(j =1; j <=n; j++)
00105     {
00106     C(i,j) = f(a + double(i-1)*hx, c + double(j-1)*hy);
00107     C(i,j) = 0.0;
00108     }}
00109 
00110     C(5,5)   = 1.0;
00111     C(n-3,n-3) = 1.0;
00112 
00113     Mgraphics.contour(C);
00114     Mgraphics.frame();
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126     Mgraphics.surface(C);
00127     Mgraphics.frame();
00128 
00129 
00130    cout << " Program End : Hit Any Key to Terminate " << endl;
00131    getchar();
00132    return 0;
00133 }