예제 #1
0
        public void DotProductBudget()
        {
            Utils.ProcessInEnv(env =>
            {
                CryptoTracker.Reset();
                Console.WriteLine("fresh {0}", CryptoTracker.TestVectorBudget(enc1 as EncryptedSealBfvVector, env as EncryptedSealBfvEnvironment));
                CryptoTracker.Reset();

                var res = enc1.DotProduct(enc2, env);
                Console.WriteLine("enc dot product {0}", CryptoTracker.TestVectorBudget(res as EncryptedSealBfvVector, env as EncryptedSealBfvEnvironment));
                CryptoTracker.Reset();
                var res_p = enc1.DotProduct(plain2, env);
                Console.WriteLine("plain dot product {0}", CryptoTracker.TestVectorBudget(res_p as EncryptedSealBfvVector, env as EncryptedSealBfvEnvironment));
                CryptoTracker.Reset();
                var res_s = enc1.SumAllSlots(env);
                Console.WriteLine("sum slots {0}", CryptoTracker.TestVectorBudget(res_s as EncryptedSealBfvVector, env as EncryptedSealBfvEnvironment));
                CryptoTracker.Reset();
                var res_m = enc1.PointwiseMultiply(plain2, env);
                Console.WriteLine("plain multiplication {0}", CryptoTracker.TestVectorBudget(res_m as EncryptedSealBfvVector, env as EncryptedSealBfvEnvironment));
                CryptoTracker.Reset();
                var res_em = enc1.PointwiseMultiply(enc2, env);
                Console.WriteLine("enc multiplication {0}", CryptoTracker.TestVectorBudget(res_em as EncryptedSealBfvVector, env as EncryptedSealBfvEnvironment));
                CryptoTracker.Reset();
            }, Factory);
        }
예제 #2
0
        public virtual IMatrix GetNext()
        {
            if (!layerPrepared)
            {
                Prepare();
            }
            var m = Source.GetNext();

#if DEBUG
            Trace = Environment.StackTrace;
#endif
            if (Verbose)
            {
                OperationsCount.Reset();
                DateTime start = DateTime.Now;
                var      res   = Apply(m);
                var      end   = DateTime.Now;
                Console.WriteLine("Layer {0} computed in {1} seconds ({2} -- {3}) layer width ({4},{5})", this.GetType().Name, (end - start).TotalSeconds, start.ToString("hh:mm:ss.fff"), end.ToString("hh:mm:ss.fff"), m.RowCount, m.ColumnCount);
                CryptoTracker.TestBudget(res.GetColumn(0), Factory);

                OperationsCount.Print();
                if (res != m)
                {
                    m.Dispose();
                }
                return(res);
            }
            else
            {
                var res = Apply(m);
                if (res != m)
                {
                    m.Dispose();
                }
                return(res);
            }
        }