Moving a peak

Hello everyone,

I would like to focus a letter E as a function of the position of correlation peak:
But there is a problem in the compilation, and I see it.

[CODE] # include "math.h"
# Include "conio.h"
# Include "stdio.h"
# Include "stdlib.h"
# Include "alloc.h"



main ()
{
long int n2, kk, k, ll, ii, jj, nn, coorx, Coory;
int su, i;
arch0 char [30], Arch1 [30]
float huge * ts huge * cr;
float vmax;

printf ("\ n \ size of the file:");
scanf ("% d", & dim);
n2 = (long) dim * (long) dim;
farcalloc ct = (n2, 4);
farcalloc cr = (n2, 4);

if (cr == NULL | | ct == NULL) {printf ("\ n Memory error.") exit (0);}

printf ("\ n \ n Enter Cross-correlation matrix:");
scanf ("% s", & arch0);
i = disco (arch0, Sun, Sun, 1 cr, 4);
if (i! = 1) goto end;

printf ("\ n \ n Enter the matrix translat ,:");
scanf ("% s", & Arch1);
i = disco (Arch1, dim, dim, 1, ct, 4);
if (i! = 1) goto end;

vmax = cr [0];
for (ii = 0 ii <dim; ii + +)
{
ll = (long) dim * (long) ii;
for (jj = 0; jj <dim; jj + +)
{
nn = ll + dd;
if (cr [nn]> vmax)
{
vmax = cr [nn];
coorx = ii;
Coory = dd;
}
}
}

for (kk = 0; kk <n2; kk + +)
{
rc [kk] = 0;
}
coorx coorx = - dim / 2;
Coory Coory = - dim / 2;



for (ii = abs (coorx) ii <dim abs (coorx) ii + +)
{
ll = (long) dim * (long) ii;
for (dd = abs (Coory) jj <dim abs (Coory) dd + +)
{
cr [(long) dim * (ii-coorx) + dd-Coory] = ct [(long) dim * (long) ii + jj];
}

}

printf ("\ n \ nIntroduire the name of the array centered ,:");
scanf ("% s", & Arch1);
i = disco (Arch1, Sun, Sun, 2 cr, 4);
if (i! = 1) goto end;

end:
farfree (cr);
farfree (ct);
return (0);
} [/ CODE]


Thank you in advance
Last edited on
What's the error?

Why the huge/far pointers? Those apply to segmented architectures.

Shouldn't
1
2
farcalloc ct = (n2, 4);
farcalloc cr = (n2, 4);
be
1
2
ct = farcalloc(n2, 4);
cr = farcalloc(n2, 4);
the error is reported in line 5, try to compile to see the error
And what line is line 5?

If you're not prepared to say what the error is and what line of code that is, you're pretty much on your own as you haven't said what the OS or compiler is and as I've already pointed out, your code uses vendor specific extensions.

EDIT: what is: arch0 char [30], Arch1 [30 ?
Last edited on
My operating system: Windows 7
Compiler: Bloodshed Dev-C + +

Line 5: # include "alloc.h"
You don't need alloc.h, just remove the line.

You still haven't explained why you're using huge and far pointers or why you're using farcalloc/farfree instead of calloc/free.
This program and others are given by my framing of PFE, which is why I find it difficult to understand.et I am obliged to work with them.
So if possible you can give me your email so I send you all the programs and discussions about the desired objective.

Thank you
You can contact me thru the forum's PM.
Good evening,
My program hangs here:i=disco(arch0,dim,dim,1,cr,4);

With this error:
can not convert `float * 'to` char *' for argument `5 'to` int disco (char *, int, int, int, char *, int)'

I have to use char * in the parameter 5, while I like the variable cr float *.

Is there a solution for me to keep char * and at the same time take the information that arrives from float.sinon how I will do to resolve this error?






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include  
<math.h>
   #include  <stdio.h>
   #include  <stdlib.h>
 
int disco  (char fichero[], int nfil, int ncol, int control,char *a, int tipo);
int main(void)
  {
      long int n2,kk,k,ll,ii,jj,nn,coorx,coory; 
      int dim,i;
      char arch0[30], arch1[30];
      float  *ct,*cr;
      float vmax;

      printf("\n\ dimension du fichier:");
      scanf("%d",&dim);
      n2 = (long)dim * (long)dim ;
      
      ct = (float*)calloc(n2, sizeof(float));
      cr = (float*)calloc(n2, sizeof(float));

      if ( cr == NULL || ct == NULL ) { printf ( "\n Memory error."); exit(0); }

      printf("\n\n Introduire Cross-correlation matrice:");
      scanf("%s",arch0);
      
      
      


      i=disco(arch0,dim,dim,1,cr,4);
      if (i!=1) goto fin;

      printf("\n\n Introduire la matrice a translat‚:");
      scanf("%s",arch1);
      i=disco(arch1,dim,dim,1,ct,4);
      if (i!=1) goto fin;

      vmax=cr[0];
      for (ii=0; ii < dim; ii++)
       {
       ll =(long)dim * (long)ii;
       for (jj=0; jj < dim; jj++)
       {
       nn=ll+jj;
       if( cr[nn] > vmax )
           {
           vmax = cr[nn];
           coorx = ii;
           coory = jj;
           }
       }
    }

    for ( kk=0 ; kk < n2 ; kk++)
        {
         cr[kk] = 0;
        }
     coorx = coorx - dim/2;
     coory = coory - dim/2;



       for (ii=abs(coorx); ii < dim-abs(coorx); ii++)
       {
       ll =(long)dim * (long)ii;
       for (jj=abs(coory); jj < dim-abs(coory); jj++)
         {
        cr[(long)dim*(ii-coorx)+jj-coory]= ct[(long)dim * (long)ii+jj];
         }

        }

      printf("\n\nIntroduire le nom de la matrice centr‚:");
      scanf("%s",arch1);
      i=disco(arch1,dim,dim,2,cr,4);
      if (i!=1) goto fin;

fin:
free(cr);
free(ct);
return 0 ;
}

 /*********************************************************************\
 *                                                                     *
 *                                                                     *
 *                            DISCO.C                                  *
 *                            =======                                  *
 *                                                                     *
 *         Rutina para trasladar n£meros de cualquier tipo desde       *
 *         una  variable  de la memoria a un disco o de un disco       *
 *         a una variable de la memoria.                               *
 *                                                                     *
 *                          ---------                                  *
 *                                                                     *
 *      Par metros:                                                    *
 *                                                                     *
 *      fichero         -  Nombre del fichero del disco.               *
 *      nfil, ncol      -  N£mero de filas y columnas.                 *
 *      control         -  1 para leer del fichero.                    *
 *                         2 para grabar en el fichero.                *
 *      a               -  puntero que indica la variable.             *
 *      tipo            -  n§ de bytes por elemento de la variable.    *
 *                                                                     *
 *                                                                     *
 \*********************************************************************/


int disco  (char fichero[], int nfil, int ncol, int control,char *a, int tipo)

{
        long int n, cont, ng;
        int unidad, j, cociente, resto;

        if (control == 1)  {
                if ((unidad = open (fichero,1))  == -1)  {
                        return (-1);
                }
                cont = (long) nfil * (long) ncol * tipo;
                resto = cont % 32768;
                cociente = cont / 32768;
                for (j = 0, n = 0; j < cociente; j++,n += 32768)
                        _read (unidad, &a[n], 32768);
                _read (unidad, &a[n], resto);
                close (unidad);
                return 1;
        }
        if (control == 2)  {
                if ((unidad = creat (fichero, 200))  == -1)  {
                        return -1;
                }
                cont = (long) nfil * (long) ncol * tipo;
                resto = cont % 32768;
                cociente = cont / 32768;
                ng = 0;
                for (j = 0, n = 0; j < cociente; j++, n += 32768)
                     ng = ng + (unsigned) _write (unidad, &a[n], 32768);
                ng = ng + (unsigned) _write (unidad, &a[n], resto);
                if (ng != cont)   {
                        return 0;
                }

                close (unidad);
                return 1;
        }
        return 0;
}
Last edited on
Topic archived. No new replies allowed.