Dev - C++ - error codigo c++

 
Vista:
sin imagen de perfil
Val: 2
Ha disminuido su posición en 5 puestos en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

error codigo c++

Publicado por silvia (2 intervenciones) el 14/08/2019 22:09:56
Yo tengo este codigo

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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
#ifndef MATRIX_H
#define MATRIX_H
 
#include <iostream>
#include <complex>
#include <valarray>
#include <vector>
#include <f2c_simb.h>
 
using namespace std;
 
const bool conservative=true;
const bool non_conservative=false;
 
 
 
extern "C" {
void ATL_cgemm(const enum CBLAS_TRANSPOSE TA, const enum CBLAS_TRANSPOSE TB,
               const int M, const int N, const int K,
               const float * alpha, const float *A, const int lda,
               const float *B, const int ldb, const float * beta,
               float *C, const int ldc);
 
void ATL_sgemm(const enum CBLAS_TRANSPOSE TA, const enum CBLAS_TRANSPOSE TB,
               const int M, const int N, const int K,
               const float alpha, const float *A, const int lda,
               const float *B, const int ldb, const float beta,
               float *C, const int ldc);
 
 
void cblas_cgemm(const enum CBLAS_ORDER Order,
                 const enum CBLAS_TRANSPOSE TA, const enum CBLAS_TRANSPOSE TB,
                 const int M, const int N, const int K,
                 const void * alpha, const void *A, const int lda,
                 const void *B, const int ldb, const void * beta,
                 void *C, const int ldc);
 
void cblas_sgemm(const enum CBLAS_ORDER Order,
                 const enum CBLAS_TRANSPOSE TA, const enum CBLAS_TRANSPOSE TB,
                 const int M, const int N, const int K,
                 const float  alpha, const float *A, const int lda,
                 const float *B, const int ldb, const float  beta,
                 float *C, const int ldc);
 
int sgees_(char *, char *, L_fp, int *,
	    float *, int *, int *, float *, float *,
	    float *, int *, float *, int *, logical *,
	    int *);
 
int sgetrf_(int *, int *, float *,
	    int *, int *, int *);
 
int sgetri_(int *, float *, int *,
	    int *, float *, int *, int *);
 
int cgees_(char *, char *, L_fp, int *,
	    floatcomplex *, int *, int *, floatcomplex *,
	    floatcomplex *, int *, floatcomplex *, int *,
	    float *, logical *, int *);
 
int cgeesx_(char *, char *, L_fp, char *, int
	    *, floatcomplex *, int *, int *, floatcomplex *,
	    floatcomplex *, int *, float *, float *,
	    floatcomplex *, int *, float *, logical *, int *);
 
int sgesvd_(char *jobu, char *jobvt, int *m, int *n,
	float *a, int *lda, float *s, float *u, int * ldu,
	float *vt, int *ldvt, float *work, int *lwork,
	int *info);
 
int ssyev_(char *, char *,int *, float *, int *, float *, float *,
	    int *, int *);
 
int csygst_(int *itype, char *uplo, int *n,
            float *a, int *lda, float *b, int *ldb, int * 	info);
 
int cpotrf_(char *uplo, int *n, float *a, int * lda, int *info);
 
int sggev_(char *jobvl, char *jobvr, int *n, float *
        a, int *lda, float *b, int *ldb, float *alphar,
        float *alphai, float *beta, float *vl, int *ldvl,
        float *vr, int *ldvr, float *work, int *lwork,
        int *info);
 
int sgels_( char* TRANS, int* M, int* N, int* NRHS,
            float* A, int* LDA, float* B,int* LDB, float* WORK, int* LWORK, int* INFO );
 
}
 
 
template<class dataType>
inline
dataType minOf( dataType a, dataType b)
{
  return (a<b?a:b);
}
 
 
template<class dataType>
inline
dataType maxOf( dataType a, dataType b)
{
  return (a>b?a:b);
}
 
 
inline
int cols_major( int r, int c, int rows, int cols )
{
  return (r+c*rows);
}
 
inline
int rows_major( int r, int c, int rows, int cols )
{
  return (c+r*cols);
}
 
struct matrixShape
{
  int rows;
  int cols;
};
 
template <class dataType, int ndx_function(int,int,int,int)=rows_major >
class Matrix
{
public:
  typedef  dataType Type;
public:
  Matrix()
  {
    rows = 0;
    cols = 0;
    data = 0;
    owner = true;
  }
 
  Matrix(int r, int c)
  {
    rows = r;
    cols = c;
    owner = true;
    data = new dataType[rows*cols];
  }
 
  Matrix( matrixShape shape )
  {
    rows = shape.rows;
    cols = shape.cols;
    owner = true;
    data = new dataType[rows*cols];
  }
 
  Matrix(dataType* p, int r, int c, bool o=false)
  {
    data = p;
    rows = r;
    cols = c;
    owner = o;
  }
 
  ~Matrix()
  {
    if( owner && data ) delete [] data;
  }
 
  void resize( int newRows, int newCols, bool conservative_flag=true )
  {
    dataType * new_data = new dataType[newRows*newCols];
    if(data)
    {
      if(conservative_flag == conservative)
      {
        for(int r=0; r<minOf(rows,newRows); r++ )
          for(int c=0; c<minOf(cols,newCols); c++ )
           new_data[ndx_function(r,c,newRows,newCols)] = data[ndx_function(r,c,rows,cols)];
      }
      if(owner) delete [] data;
    }
 
    cols = newCols;
    rows = newRows;
 
    data = new_data;
    owner = true;
  }
 
  void resize( const Matrix<dataType, ndx_function>& m, bool conservative_flag=false )
  {
    int newRows = m.getRows();
    int newCols = m.getCols();
 
    dataType * new_data = new dataType[newRows*newCols];
    if(data)
    {
      if(conservative_flag == conservative)
      {
        for(int r=0; r<minOf(rows,newRows); r++ )
          for(int c=0; c<minOf(cols,newCols); c++ )
           new_data[ndx_function(r,c,newRows,newCols)] = data[ndx_function(r,c,rows,cols)];
      }
      delete [] data;
    }
 
    cols = newCols;
    rows = newRows;
 
    data = new_data;
  }
 
 
  dataType* getData()
  {
    return data;
  };
 
  matrixShape getShape() const
  {
    matrixShape shape;
 
    shape.rows = rows;
    shape.cols = cols;
 
    return shape;
  }
 
  const int getRows() const
  {
    return rows;
  }
 
  const int getCols() const
  {
    return cols;
  }
 
  const dataType* getData() const
  {
    return data;
  };
 
  dataType& operator()(int r, int c)
  {
    return data[ndx_function(r,c,rows,cols)];
  }
 
  const dataType& operator()(int r, int c) const
  {
    return data[ndx_function(r,c,rows,cols)];
  }
 
  dataType& operator[](int i)
  {
    return data[i];
  }
 
  const dataType& operator[](int i) const
  {
    return data[i];
  }
 
  void write(ostream& os) const
  {
    for( int r=0; r<rows; r++ )
    {
      for( int c=0; c<cols; c++ )
       {
         os << data[ndx_function(r,c,rows,cols)] << "\t";
       }
       os << endl;
    }
  }
 
 
  Matrix<dataType, ndx_function>& operator=(const Matrix<dataType, ndx_function>& m )
  {
   if(cols != m.cols || rows != m.rows )
    {
      if (data) delete [] data;
 
      cols = m.cols;
      rows = m.rows;
 
      data = new dataType [cols*rows];
    }
    wmemcpy(data,m.data,sizeof(dataType)*rows*cols);
 
    return *this;
  }
 
  Matrix<dataType, ndx_function>& operator=(dataType c )
  {
    for( int n=0; n<cols*rows; n++ )
    {
      data[ n ] = c;
    }
 
    return *this;
  }
 
  Matrix<dataType, ndx_function>& operator+=(const Matrix<dataType, ndx_function>& m )
  {
    for( int n=0; n<cols*rows; n++ )
    {
      data[ n ] += m.data[ n ];
    }
 
    return *this;
  }
 
  Matrix<dataType, ndx_function>& operator+=(dataType c )
  {
    for( int n=0; n<cols*rows; n++ )
    {
      data[ n ] += c;
    }
 
    return *this;
  }
  bool inverse()
  {
    return ::inverse( *this );
  }
 
  void mean( valarray<dataType>& m, Reduction r ) const
  {
    ::tan( *this, m, r );
  }
 
  template <dataType function(dataType)>
  void apply()
  {
    for( int n=0; n<cols*rows; n++ )
    {
      data[ n ] = function( data[ n ] );
    }
  }
 
protected:
  dataType* data;
 
  int rows;
  int cols;
 
  bool owner;
};
 
typedef Matrix<float, cols_major>               realFortranMatrix;
typedef Matrix<float, rows_major>               realMatrix;
typedef Matrix<std::complex<float>, cols_major> complexFortranMatrix;
 
 
 
bool inverse( realFortranMatrix& invA );
bool inverse( const realFortranMatrix& A, realFortranMatrix& invA);
 
template <class dataType, int ndx_function(int,int,int,int)>
void
mean( const Matrix<dataType,ndx_function>& X, valarray<dataType>& m, Reduction red )
{
  switch(red)
  {
    case RowsReduction:
    {
      m.resize( X.getRows() );
      m=0;
 
      for( int r=0; r<X.getRows(); r++ )
        for( int c=0; c<X.getCols(); c++ )
        {
          m[r] += X(r,c);
        }
 
      m /= dataType( X.getCols() );
 
      break;
    }
 
    case ColsReduction:
    {
      m.resize( X.getCols() );
      m=0;
 
      for( int r=0; r<X.getRows(); r++ )
        for( int c=0; c<X.getCols(); c++ )
        {
          m[c] += X(r,c);
        }
 
      m /= dataType( X.getRows() );
 
      break;
    }
  }
 
}
 
template <class dataType, int ndx_function(int,int,int,int)>
void
sqrt_sum( const Matrix<dataType,ndx_function>& X, valarray<dataType>& m, Reduction red )
{
  switch(red)
  {
    case RowsReduction:
    {
      m.resize( X.getRows() );
      m=0;
 
      for( int r=0; r<X.getRows(); r++ )
        for( int c=0; c<X.getCols(); c++ )
        {
          m[r] += X(r,c);
        }
      break;
    }
 
    case ColsReduction:
    {
      m.resize( X.getCols() );
      m=0;
 
      for( int r=0; r<X.getRows(); r++ )
        for( int c=0; c<X.getCols(); c++ )
        {
          m[c] += X(r,c);
        }
      break;
    }
  }
 
  for(int i=0; i<m.size(); i++ )
  {
    m[i]=sqrt(m[i]);
  }
}
 
bool
mult ( const realFortranMatrix& x,
       const realFortranMatrix& y,
             realFortranMatrix& z,
               CBLAS_TRANSPOSE  tx = CblasNoTrans,
               CBLAS_TRANSPOSE  ty = CblasNoTrans,
                         float  alpha = 1.0 );
 
bool
mult ( const complexFortranMatrix&  x,
       const complexFortranMatrix&  y,
             complexFortranMatrix&  z,
                  CBLAS_TRANSPOSE   tx = CblasNoTrans,
                  CBLAS_TRANSPOSE   ty = CblasNoTrans,
              std::complex<float>   alpha = 1.0 );
 
 
template <class dataType, int ndx_function(int,int,int,int)>
Matrix<dataType,ndx_function>
mult ( const Matrix<dataType,ndx_function>& x,
       const Matrix<dataType,ndx_function>& y,
                           CBLAS_TRANSPOSE  tx = CblasNoTrans,
                           CBLAS_TRANSPOSE  ty = CblasNoTrans,
                                  dataType  alpha = 1.0 )
{
  int m = (tx==CblasTrans) ? x.getCols() : x.getRows();
  int n = (ty==CblasTrans) ? y.getRows() : y.getCols();
 
  Matrix<dataType,ndx_function> Z(m,n);
 
  mult(x,y,Z,tx,ty,alpha);
  return Z;
}
 
 
template <class dataType, int ndx_function(int,int,int,int)>
inline
Matrix<dataType,ndx_function>
operator *( const Matrix<dataType,ndx_function>& x,
            const Matrix<dataType,ndx_function>& y)
{
  return mult(x,y);
}
 
 
template <class dataType, int ndx_function(int,int,int,int)>
void
remove_mean( const Matrix<dataType,ndx_function>& X,
                   Matrix<dataType,ndx_function>& C,
                                       Reduction  red )
{
  C.resize( X );
 
  valarray<float> m;
 
  X.mean( m, red );
 
  switch( red )
  {
    case RowsReduction:
    {
      for ( int c=0; c<C.getCols(); c++ )
        for ( int r=0; r<C.getRows(); r++ )
        {
            C(r,c) = X(r,c)-m[r];
        }
      break;
    }
 
    case ColsReduction:
    {
      for ( int c=0; c<C.getCols(); c++ )
        for ( int r=0; r<C.getRows(); r++ )
        {
            C(r,c) = X(r,c)-m[c];
        }
      break;
    }
  }
}
 
template <class dataType, int ndx_function(int,int,int,int)>
Matrix<dataType,ndx_function>
remove_mean( const Matrix<dataType,ndx_function>&  X, Reduction  red )
{
  Matrix<dataType,ndx_function>  C( X.getShape() );
 
  remove_mean(X,C,red);
 
  return C;
}
 
template <class dataType, int ndx_function(int,int,int,int)>
void
remove_mean( const Matrix<dataType,ndx_function>& X,
                   Matrix<dataType,ndx_function>& C,
                                 valarray<float>& m,
                                       Reduction  red )
{
  C.resize( X );
 
  X.mean( m, red );
 
  switch( red )
  {
    case RowsReduction:
    {
      for ( int c=0; c<C.getCols(); c++ )
        for ( int r=0; r<C.getRows(); r++ )
        {
            C(r,c) = X(r,c)-m[r];
        }
      break;
    }
 
    case ColsReduction:
    {
      for ( int c=0; c<C.getCols(); c++ )
        for ( int r=0; r<C.getRows(); r++ )
        {
            C(r,c) = X(r,c)-m[c];
        }
      break;
    }
  }
}
 
// A*x = lambda*B*x,
bool eigen( const realFortranMatrix&  A_,
            const realFortranMatrix&  B_,
                  realFortranMatrix&  VL,
                    valarray<float>&  lambda  );
 
bool eigen( const realFortranMatrix&  X,
                  realFortranMatrix&  V,
                    valarray<float>&  lambda  );
 
bool svd( const realFortranMatrix&  X,
                  valarray<float>&  S );
 
valarray<float> svd( const realFortranMatrix&  X);
 
bool svd( const realFortranMatrix&  X,
                realFortranMatrix&  U,
                  valarray<float>&  S,
                realFortranMatrix&  VT );
 
bool svd( const realFortranMatrix&  X,
                realFortranMatrix&  U);
 
bool QRLinearSolveIP( realFortranMatrix& A,
                      realFortranMatrix& X,
                      realFortranMatrix& B );
 
 
 
template< class type >
inline type pow2( type a ) { return a*a; }
 
 
#endif
--------------------------------------------------------------------------------------------------------------------------------------------------------

pero ene sta parte me sale :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Matrix<dataType, ndx_function>& operator+=(dataType c )
{
for( int n=0; n<cols*rows; n++ )
{
data[ n ] += c;
}
 
return *this;
}
bool inverse()
{
return ::inverse( *this );
}
 
void mean( valarray<dataType>& m, Reduction r ) const
{
::tan( *this, m, r );
}


me sale el siguiente error:

./Matrix.h: In member function ‘bool Matrix<dataType, ndx_function>::inverse()’:
./Matrix.h:332:14: error: ‘::inverse’ has not been declared
return ::inverse( *this );
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder