Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.8 KiB

  1. /*******************************************************
  2. *
  3. * outDict.h
  4. *
  5. * Defines data structures for sparse matrices
  6. *
  7. * In addition to the basic single spare matrix data structure
  8. * there is a bi-sparse matric version. This version supports
  9. * the case when you have 2 separate sparse matrices that are
  10. * guranteed to have the exact same sparsnes structure. These version
  11. * all have a "2" appended to their data structures. Using this instead
  12. * of simply 2 basic sparse matricies will give a speed performance
  13. * improvement when accessing an element at run time.
  14. *
  15. * HISTORY
  16. * Introduced April 2002 (mrevow) based on the out-of-dictionary implemetation
  17. *
  18. ******************************************************/
  19. #ifndef H_SPARSE_MATRIX_H
  20. #define H_SPARSE_MATRIX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /*
  25. * A sparse matrix is a cRow cCol matrix having a lot of default values
  26. * which are stored in a simple fashion The header contains
  27. * offsets to each row in the table. Each row then only keeps
  28. * the non-default values
  29. */
  30. #define HEADER_ID 0xFDFDFD01
  31. #define HEADER_ID2 0xFDFDFD02
  32. // Sparse matrix type
  33. typedef unsigned short SPARSE_TYPE;
  34. // The same structure for the Bi-sparse matrix implementation
  35. typedef struct tagSPARSE_TYPE2
  36. {
  37. SPARSE_TYPE v1; // First value
  38. SPARSE_TYPE v2; // First value
  39. } SPARSE_TYPE2;
  40. // SPARSE matrix index type
  41. typedef unsigned short SPARSE_IDX;
  42. // Describes a row of the sparse matrix. Keeps a table of which columns
  43. // are present in the row
  44. typedef struct tagSPARSE_ROW
  45. {
  46. SPARSE_IDX *pColId; // List of column entries present
  47. SPARSE_TYPE *pVals; // Values at each column position
  48. } SPARSE_ROW;
  49. // The same structure for the Bi-sparse matrix implementation
  50. typedef struct tagSPARSE_ROW2
  51. {
  52. SPARSE_IDX *pColId; // List of column entries present
  53. SPARSE_TYPE2 *pVals; // Values at each column position
  54. } SPARSE_ROW2;
  55. // The actual sparse matrix structure
  56. typedef struct tagSPARSE_MATRIX
  57. {
  58. UINT id; // Header id (integrity check and distinguishes single from bi)
  59. UINT iSize; // Size of sparse data stored in Bytes
  60. UINT cRow; // Full matrix is cRow x cCol
  61. UINT cCol; // Number of columns
  62. SPARSE_TYPE iDefaultVal; // Default value (In Bi-sparse matrices must be same value)
  63. SPARSE_IDX *pRowCnt; // Count at each row
  64. SPARSE_IDX *pRowOffset; // Offsets in data to each of the cDim rows
  65. BYTE *pData; // Rows of sparse matrix data. Each row is of type SPARSE_ROW
  66. } SPARSE_MATRIX;
  67. extern SPARSE_TYPE lookupSparseMat(SPARSE_MATRIX *pSparseMat, UINT i, UINT j);
  68. extern SPARSE_TYPE2 *lookupSparseMat2(SPARSE_MATRIX *pSparseMat, UINT i, UINT j);
  69. extern BOOL InitializeSparseMatrix(HINSTANCE hInst, int iKey, SPARSE_MATRIX *pSparseMat);
  70. extern BOOL loadSparseMatrixFromFp(char *fname, SPARSE_MATRIX *pSparseMat);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif // H_SPARSE_MATRIX_H