コード例 #1
0
        /// <summary>
        /// Returns a mapping from this OM to dstOM
        /// </summary>
        /// <param name="dstOm"></param>
        /// <returns>A dictionary from source(grade, column, row) to dest(column, row, multiplier).
        /// column = domainIdx, row = rangeIdx.
        /// </returns>
        public Dictionary <Tuple <int, int, int>, Tuple <int, int, double> > getMapping(OM dstOm)
        {
            Dictionary <Tuple <int, int, int>, Tuple <int, int, double> > map = new Dictionary <Tuple <int, int, int>, Tuple <int, int, double> >();

            // loop over all grades, loop over all entries of each grade to find match
            for (int gradeIdx = 0; gradeIdx < dstOm.Domain.Length; gradeIdx++)
            {
                for (int dstDomainIdx = 0; dstDomainIdx < dstOm.Domain[gradeIdx].Length; dstDomainIdx++)
                {
                    for (int srcDomainIdx = 0; srcDomainIdx < this.Domain[gradeIdx].Length; srcDomainIdx++)
                    {
                        // check if domain matches
                        if (this.Domain[gradeIdx][srcDomainIdx].bitmap != dstOm.Domain[gradeIdx][dstDomainIdx].bitmap)
                        {
                            continue;
                        }
                        for (int dstRangeIdx = 0; dstRangeIdx < dstOm.Range[gradeIdx].Length; dstRangeIdx++)
                        {
                            for (int srcRangeIdx = 0; srcRangeIdx < this.Range[gradeIdx].Length; srcRangeIdx++)
                            {
                                // check if range matches
                                if (this.Range[gradeIdx][srcRangeIdx].bitmap != dstOm.Range[gradeIdx][dstRangeIdx].bitmap)
                                {
                                    continue;
                                }

                                // compute multiplier
                                double multiplier = (dstOm.Range[gradeIdx][dstRangeIdx].scale / this.Range[gradeIdx][srcRangeIdx].scale) *
                                                    (dstOm.Domain[gradeIdx][dstDomainIdx].scale / this.Domain[gradeIdx][srcDomainIdx].scale);

                                map.Add(new Tuple <int, int, int>(gradeIdx, srcDomainIdx, srcRangeIdx),
                                        new Tuple <int, int, double>(dstDomainIdx, dstRangeIdx, multiplier));
                            } // end of loop over srcRangeIdx
                        }     // end of loop over dstRangeIdx
                    }         // end of loop over srcDomainIdx
                }             // end of loop over dstDomainIdx
            }                 // end of loop over gradeIdx

            return(map);
        }
コード例 #2
0
ファイル: om.cs プロジェクト: Sciumo/gaigen
        /// <summary>
        /// Returns a mapping from this OM to dstOM
        /// </summary>
        /// <param name="dstOm"></param>
        /// <returns>A dictionary from source(grade, column, row) to dest(column, row, multiplier). 
        /// column = domainIdx, row = rangeIdx.
        /// </returns>
        public Dictionary<Tuple<int, int, int>, Tuple<int, int, double>> getMapping(OM dstOm)
        {
            Dictionary<Tuple<int, int, int>, Tuple<int, int, double>> map = new Dictionary<Tuple<int, int, int>, Tuple<int, int, double>>();
            // loop over all grades, loop over all entries of each grade to find match
            for (int gradeIdx = 0; gradeIdx < dstOm.Domain.Length; gradeIdx++)
            {
                for (int dstDomainIdx = 0; dstDomainIdx < dstOm.Domain[gradeIdx].Length; dstDomainIdx++)
                {
                    for (int srcDomainIdx = 0; srcDomainIdx < this.Domain[gradeIdx].Length; srcDomainIdx++)
                    {
                        // check if domain matches
                        if (this.Domain[gradeIdx][srcDomainIdx].bitmap != dstOm.Domain[gradeIdx][dstDomainIdx].bitmap) continue;
                        for (int dstRangeIdx = 0; dstRangeIdx < dstOm.Range[gradeIdx].Length; dstRangeIdx++)
                        {
                            for (int srcRangeIdx = 0; srcRangeIdx < this.Range[gradeIdx].Length; srcRangeIdx++)
                            {
                                // check if range matches
                                if (this.Range[gradeIdx][srcRangeIdx].bitmap != dstOm.Range[gradeIdx][dstRangeIdx].bitmap) continue;

                                // compute multiplier
                                double multiplier = (dstOm.Range[gradeIdx][dstRangeIdx].scale / this.Range[gradeIdx][srcRangeIdx].scale) *
                                    (dstOm.Domain[gradeIdx][dstDomainIdx].scale / this.Domain[gradeIdx][srcDomainIdx].scale);

                                map.Add(new Tuple<int, int, int>(gradeIdx, srcDomainIdx, srcRangeIdx),
                                    new Tuple<int, int, double>(dstDomainIdx, dstRangeIdx, multiplier));

                            } // end of loop over srcRangeIdx
                        } // end of loop over dstRangeIdx
                    } // end of loop over srcDomainIdx
                } // end of loop over dstDomainIdx
            } // end of loop over gradeIdx

            return map;
        }