Esempio n. 1
0
        public static TVector <T> operator-(TVector <T> val1, TVector <T> val2)
        {
            TVector <T> ret = val1.HClone();

            ret.Sub(val2);
            return(ret);
        }
Esempio n. 2
0
        public static TVector <T> operator +(TVector <T> val1, T val2)
        {
            TVector <T> ret = val1.HClone();

            ret.Add(val2);
            return(ret);
        }
Esempio n. 3
0
        public static TVector <double> GetVectorLarge(string name, bool bUseFile = false)
        {
            TVector <double> vector;

            try
            {
                Execute("htlib2_matlab_GetVector = " + name + ";");
                int size = GetValueInt("length(htlib2_matlab_GetVector)");
                if (size < TVector <double> .MaxBlockCapacity)
                {
                    System.Array real = new double[size];
                    System.Array imag = new double[size];
                    matlab.GetFullMatrix("htlib2_matlab_GetVector", "base", ref real, ref imag);
                    Execute("clear htlib2_matlab_GetVector;");
                    vector = new TVector <double>(size);
                    for (int i = 0; i < size; i++)
                    {
                        vector[i] = (double)real.GetValue(i);
                    }
                }
                else
                {
                    HDebug.Assert(bUseFile, _path_temporary != null);
                    string tmppath = HFile.GetTempPath(_path_temporary, ".dat");
                    Execute("htlib2_matlab_GetVectorLarge.vec = " + name + ";");
                    {
                        Execute("htlib2_matlab_GetVectorLarge.fid=fopen('" + tmppath + "','w');");
                        Execute("htlib2_matlab_GetVectorLarge.vec=fwrite(htlib2_matlab_GetVectorLarge.fid,htlib2_matlab_GetVectorLarge.vec','double');");
                        Execute("fclose(htlib2_matlab_GetVectorLarge.fid);");
                        Execute("clear htlib2_matlab_GetVectorLarge;");
                    }
                    {
                        bool clear_var = false;
                        if (clear_var)
                        {
                            Execute("clear " + name + ";");
                        }
                    }
                    vector = new TVector <double>(size);
                    {
                        System.IO.BinaryReader reader = new System.IO.BinaryReader(new System.IO.FileStream(tmppath, System.IO.FileMode.Open));
                        for (long i = 0; i < size; i++)
                        {
                            vector[i] = reader.ReadDouble();
                        }
                        reader.Close();
                    }
                    HFile.Delete(tmppath);
                    return(vector);
                }
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                HDebug.Assert(false);
                vector = null;
            }
            return(vector);
        }
Esempio n. 4
0
 public TVector(TVector <T> src)
 {
     this.SizeLong = src.SizeLong;
     this.data     = new T[src.data.Length][];
     for (int i = 0; i < data.Length; i++)
     {
         data[i] = src.data[i].HClone();
     }
 }
Esempio n. 5
0
        public static TVector <int> GetVectorLargeInt(string name, bool bUseFile = false)
        {
            TVector <double> real   = GetVectorLarge(name, bUseFile);
            TVector <int>    vector = new TVector <int>(real.SizeLong);

            for (long i = 0; i < vector.SizeLong; i++)
            {
                vector[i] = Double2Int(real[i]);
            }
            return(vector);
        }
Esempio n. 6
0
 public void Sub(TVector <T> val)
 {
     HDebug.Assert(SizeLong == val.SizeLong);
     for (int i = 0; i < data.Length; i++)
     {
         T[] datai     = data[i];
         T[] val_datai = val.data[i];
         for (int j = 0; j < datai.Length; j++)
         {
             datai[j] = (dynamic)datai[j] - val_datai[j];
         }
     }
 }
Esempio n. 7
0
 public static bool Equals(TVector <T> val1, TVector <T> val2)
 {
     if (val1.SizeLong != val2.SizeLong)
     {
         return(false);
     }
     for (long i = 0; i < val1.SizeLong; i++)
     {
         if ((dynamic)val1[i] != val2[i])
         {
             return(false);
         }
     }
     return(true);
 }