Scarica il sorgente database/2000-matrici-v2.02.02.h
  1. //********************************************//
  2. //************* matrici v2.02.02 *************//
  3. //**************** by mamo139 ****************//
  4. //******* http://mamo139.altervista.org ******//
  5. //********************************************//
  6.  
  7. #ifndef _MATRICI_H
  8. #define _MATRICI_H 1
  9.  
  10. #include <cstdlib>
  11. #include <iostream>
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <math.h>
  16.  
  17.  
  18. //costanti
  19. typedef enum {
  20. MATRICI_CUT_ROW,
  21. MATRICI_CUT_COLUMN
  22. } matrici_cut_mode;
  23.  
  24. typedef enum {
  25. MATRICI_JOIN_HORIZONTALLY,
  26. MATRICI_JOIN_VERTICALLY
  27. } matrici_join_mode;
  28.  
  29. //**************** class ******************//
  30.  
  31. class matrice {
  32. private:
  33. int r;
  34. int c;
  35. double ** m;
  36.  
  37. public:
  38. //costruttore e distruttore
  39. matrice();
  40. matrice(const matrice& o);//copy constructor
  41. ~matrice();
  42.  
  43. //crea matrice
  44. void create(int r, int c);
  45. void create_with_value(int r, int c, double value);
  46.  
  47. //visualizza matrice
  48. void print();
  49.  
  50. //info matrice
  51. int rows();
  52. int columns();
  53. double get_value(int r0, int c0);
  54. void set_value(int r0, int c0, double value);
  55. double *operator[](int i);
  56.  
  57. //caricamento - salvataggio matrici
  58. void load_from_file(char * file);
  59. void save_in_file(char * file);
  60.  
  61. //assignment operator
  62. matrice operator=(const matrice o);
  63.  
  64. //operazioni matrici con matrici
  65. friend matrice operator+(matrice a, matrice b);
  66. friend matrice operator-(matrice a, matrice b);
  67. friend matrice operator*(matrice a,matrice b);
  68.  
  69. //operazioni matrici con scalari
  70. friend matrice operator+(double scal,matrice a);
  71. friend matrice operator+(matrice a, double scal);
  72. friend matrice operator-(double scal,matrice a);
  73. friend matrice operator-(matrice a, double scal);
  74. friend matrice operator*(double scal,matrice a);
  75. friend matrice operator*(matrice a, double scal);
  76.  
  77. //altre operazioni
  78. friend matrice matrici_transpose(matrice a);
  79. friend double matrici_determinant(matrice a);
  80. friend matrice matrici_invert(matrice a);
  81.  
  82. //modifica matrici
  83. friend matrice matrici_cut(matrice a, matrici_cut_mode mode, int pos);
  84. friend matrice matrici_join(matrice a, matrice b, matrici_join_mode mode);
  85.  
  86.  
  87. };
  88.  
  89.  
  90. #endif
  91.