Ignore:
Timestamp:
Jan 25, 2025, 5:59:05 PM (11 months ago)
Author:
Fangren Yu <f37yu@…>
Branches:
master
Children:
11f92fac
Parents:
1fb0a883
Message:

try to fix cost table one more time, add some comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/BasicTypes-gen.cpp

    r1fb0a883 r2a5345b  
    135135static Kind commonTypeMatrix[NUMBER_OF_BASIC_TYPES][NUMBER_OF_BASIC_TYPES];
    136136
    137 // Fangren explain shortest cost algorithm.
     137// Compute the minimal conversion costs using Dijkstra's algorithm
    138138void generateCosts( int row ) {
    139139        bool seen[NUMBER_OF_BASIC_TYPES] = { false /*, ... */ };
     
    176176
    177177                // traverse children
    178                 // Fangren explain "max"
     178                // any conversion should have a cost of at least 1, even if between types of equal rank
    179179                int i = graph[col].left;
    180180                if ( i == -1 ) continue;                                                // leaf
     
    191191} // generateCosts
    192192
    193 // Fangren explain this routine if you can.
     193// Note: this algorithm is not general.
     194// It relies on the specific structure of the conversion graph.
     195// When the common type is not one of the two given types, we should always have a real and a complex floating point type,
     196// in which case the common type is the next complex type ranked higher than the real type.
    194197void generateCommonType( int row, int col ) {                   // row <= col
    195198        if ( costMatrix[row][col] >= 0 ) {
Note: See TracChangeset for help on using the changeset viewer.