public GaNumMapUnilinearComposed ResetToMapping(IGaNumMapUnilinear firstMapping)
        {
            _mappingsList.Clear();
            _mappingsList.Add(firstMapping);

            return(this);
        }
Exemple #2
0
        /// <summary>
        /// Extract the basis vectors mappings from the given linear map and convert them into a
        /// linear map on the base vector space of the frame. This should only be used if basis vectors
        /// of the domain are mapped to vectors of the target domain.
        /// </summary>
        /// <param name="linearMap"></param>
        /// <returns></returns>
        public static double[,] BasisVectorMapsToScalarsArray(this IGaNumMapUnilinear linearMap)
        {
            var resultArray = new double[
                linearMap.TargetVSpaceDimension,
                linearMap.DomainVSpaceDimension
                              ];

            foreach (var basisVectorMap in linearMap.BasisVectorMaps())
            {
                var col   = basisVectorMap.Item1;
                var terms =
                    basisVectorMap
                    .Item2
                    .NonZeroTerms
                    .Where(t => t.Key.IsValidBasisVectorId());

                foreach (var term in terms)
                {
                    var row = term.Key;

                    resultArray[row, col] = term.Value;
                }
            }

            return(resultArray);
        }
        public GaNumMapUnilinearComposed AddMapping(IGaNumMapUnilinear map)
        {
            if (_mappingsList.Count > 0 && TargetVSpaceDimension != map.DomainVSpaceDimension)
            {
                throw new InvalidOperationException("Mapping space dimensions mismatch");
            }

            _mappingsList.Add(map);

            return(this);
        }
Exemple #4
0
        public GaNumMapUnilinearCombined AddMap(double coef, IGaNumMapUnilinear linearMap)
        {
            if (
                linearMap.DomainVSpaceDimension != DomainVSpaceDimension ||
                linearMap.TargetVSpaceDimension != TargetVSpaceDimension
                )
            {
                throw new InvalidOperationException("Linear map dimensions mismatch");
            }

            _mappingsList.Add(new GaNumMapUnilinearCombinedTerm(coef, linearMap));

            return(this);
        }
Exemple #5
0
        public static GaNumMapUnilinearCoefSums ToCoefSumsMap(this IGaNumMapUnilinear linearMap)
        {
            var resultMap = GaNumMapUnilinearCoefSums.Create(
                linearMap.DomainVSpaceDimension,
                linearMap.TargetVSpaceDimension
                );

            foreach (var basisBladeMap in linearMap.BasisBladeMaps())
            {
                resultMap.SetBasisBladeMap(basisBladeMap.Item1, basisBladeMap.Item2);
            }

            return(resultMap);
        }
        public static GaNumMapUnilinearHash Create(IGaNumMapUnilinear linearMap, IEnumerable <int> idsList)
        {
            var table = new GaNumMapUnilinearHash(
                linearMap.DomainVSpaceDimension,
                linearMap.TargetVSpaceDimension
                );

            foreach (var id1 in idsList)
            {
                var resultMv = linearMap[id1];

                if (!resultMv.IsNullOrZero())
                {
                    table._basisBladeMaps[id1] = resultMv;
                }
            }

            return(table);
        }
Exemple #7
0
        public static double[,] ToScalarsArray(this IGaNumMapUnilinear linearMap)
        {
            var resultArray = new double[
                linearMap.TargetGaSpaceDimension,
                linearMap.DomainGaSpaceDimension
                              ];

            foreach (var basisBladeMap in linearMap.BasisBladeMaps())
            {
                var col = basisBladeMap.Item1;

                foreach (var term in basisBladeMap.Item2.NonZeroTerms)
                {
                    var row = term.Key;

                    resultArray[row, col] = term.Value;
                }
            }

            return(resultArray);
        }
Exemple #8
0
 internal GaNumMapUnilinearCombinedTerm(double coef, IGaNumMapUnilinear linearMap)
 {
     Coef      = coef;
     LinearMap = linearMap;
 }
 private GaNumMapUnilinearComposed(IGaNumMapUnilinear firstMapping)
 {
     _mappingsList.Add(firstMapping);
 }
 public static GaNumMapUnilinearComposed Create(IGaNumMapUnilinear firstMappings)
 {
     return(new GaNumMapUnilinearComposed(firstMappings));
 }
Exemple #11
0
 public static Matrix ToMatrix(this IGaNumMapUnilinear linearMap)
 {
     return(DenseMatrix.OfArray(
                ToScalarsArray(linearMap)
                ));
 }
Exemple #12
0
 public static GaNumMapUnilinearMatrix ToMatrixMap(this IGaNumMapUnilinear linearMap)
 {
     return(GaNumMapUnilinearMatrix.Create(linearMap.ToMatrix()));
 }
Exemple #13
0
 public static IEnumerable <double[]> ToScalarColumnsList(this IGaNumMapUnilinear linearMap)
 {
     return(Enumerable
            .Range(0, linearMap.DomainGaSpaceDimension)
            .Select(id => linearMap[id].TermsToArray()));
 }
Exemple #14
0
 public static IEnumerable <IGaNumMultivector> ToColumnsList(this IGaNumMapUnilinear linearMap)
 {
     return(Enumerable
            .Range(0, linearMap.DomainGaSpaceDimension)
            .Select(id => linearMap[id]));
 }
Exemple #15
0
 public static Dictionary <int, IGaNumMultivector> ToDictionary(this IGaNumMapUnilinear linearMap)
 {
     return(linearMap
            .BasisBladeMaps()
            .ToDictionary(t => t.Item1, t => t.Item2));
 }