public override double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (rows <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "rows"); } if (columns <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "columns"); } if (matrix.Length < rows * columns) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix"); } var work = new double[rows]; return(SafeNativeMethods.d_matrix_norm((byte)norm, rows, columns, matrix, work)); }
/// <summary>Read norms into a pre-allocated array. </summary> public override void Norms(System.String field, byte[] bytes, int offset) { lock (this) { Norm norm = (Norm)norms[field]; if (norm == null) { Array.Copy(FakeNorms(), 0, bytes, offset, MaxDoc()); return; } if (norm.bytes != null) { // can copy from cache Array.Copy(norm.bytes, 0, bytes, offset, MaxDoc()); return; } IndexInput normStream = (IndexInput)norm.in_Renamed.Clone(); try { // read from disk normStream.Seek(norm.normSeek); normStream.ReadBytes(bytes, offset, MaxDoc()); } finally { normStream.Close(); } } }
public override void RemoveEvents() { Start.IfObjectNotNull(n => n.RemoveEvents()); End.IfObjectNotNull(n => n.RemoveEvents()); Norm.IfObjectNotNull(n => n.RemoveEvents()); base.RemoveEvents(); }
public override void UpdateEvents() { if (Start != null) { Start.SetDownTick(TickPair.Down); Start.Text = StartText; Start.UpdateEvents(); } if (End != null) { End.SetDownTick(TickPair.Up); End.Text = EndText; End.UpdateEvents(); } if (this.Loopable) { Norm.SetDownTick(GetNormTick(TickPair)); Norm.Text = NormText; Norm.UpdateEvents(); } else { if (Norm != null) { Norm.DeleteAll(); Norm = null; } } base.UpdateEvents(); }
/* Leaving this here will cause a memory leak under .NET 1.1 ~SegmentReader() { // patch for pre-1.4.2 JVMs, whose ThreadLocals leak //System.Threading.Thread.SetData(termVectorsLocal, null); } */ protected internal override void DoCommit() { if (deletedDocsDirty) { // re-write deleted deletedDocs.Write(Directory(), segment + ".tmp"); Directory().RenameFile(segment + ".tmp", segment + ".del"); } if (undeleteAll && Directory().FileExists(segment + ".del")) { Directory().DeleteFile(segment + ".del"); } if (normsDirty) { // re-write norms System.Collections.IEnumerator values = norms.Values.GetEnumerator(); while (values.MoveNext()) { Norm norm = (Norm) values.Current; if (norm.dirty) { norm.ReWrite(); } } } deletedDocsDirty = false; normsDirty = false; undeleteAll = false; }
/// <summary> /// This routine moves the points in p so that the average/min/max Y component is y and the /// average/min/max X component is x. /// </summary> public static void MovePoints(ref PointF[] p, float x, Norm xmode, float y, Norm ymode) { float dx = 0, dy = 0; Norms norms = new Norms(); norms.Add(p); switch (xmode) { case Norm.Average: dx = x - norms.avg.X; break; case Norm.Max: dx = x - norms.max.X; break; case Norm.Min: dx = x - norms.min.X; break; } switch (ymode) { case Norm.Average: dy = y - norms.avg.Y; break; case Norm.Max: dy = y - norms.max.Y; break; case Norm.Min: dy = y - norms.min.Y; break; } for (int i = 0; i < p.Length; i++) { p[i].X += dx; p[i].Y += dy; } }
private void iterate(double[][] seeds, ConcurrentStack <double[]> maxcandidates, int index) { double[] point = seeds[index]; double[] mean = new double[point.Length]; double[] delta = new double[point.Length]; // we will keep moving it in the // direction of the density modes int iterations = 0; // until convergence or max iterations reached while (iterations < MaxIterations) { iterations++; // compute the shifted mean computeMeanShift(point, mean); // extract the mean shift vector for (int j = 0; j < mean.Length; j++) { delta[j] = point[j] - mean[j]; } // update the point towards a mode for (int j = 0; j < mean.Length; j++) { point[j] = mean[j]; } // Check if we are already near any maximum point if (cut && nearest(point, maxcandidates) != null) { break; } // check for convergence: magnitude of the mean shift // vector converges to zero (Comaniciu 2002, page 606) if (Norm.Euclidean(delta) < Tolerance * Bandwidth) { break; } } if (cut) { double[] match = nearest(point, maxcandidates); if (match != null) { seeds[index] = match; } else { maxcandidates.Push(point); } } }
public void Finish() { Finished = true; Task.WaitAll(Writer); File.Close(); if (Setup) { //Write Mean float[] mean = new float[Statistics.Length]; for (int i = 0; i < mean.Length; i++) { mean[i] = Statistics[i].Mean(); } Norm.WriteLine(String.Join(Separator, Array.ConvertAll(mean, x => x.ToString(Accuracy)))); //Write Std float[] std = new float[Statistics.Length]; for (int i = 0; i < std.Length; i++) { std[i] = Statistics[i].Std(); } Norm.WriteLine(String.Join(Separator, Array.ConvertAll(std, x => x.ToString(Accuracy)))); } Norm.Close(); }
public void EuclideanTest1() { float[,] a = { { 15.4457f, 0.4187f, 15.6093f }, { 0.0000f, 2.5708f, 0.6534f } }; float[] expected = { 21.9634f, 2.6525f }; float[] actual = Norm.Euclidean(a, 1); Assert.IsTrue(expected.IsEqual(actual, 0.001f)); float[] expected2 = { 15.4457f, 2.6047f, 15.6229f }; float[] actual2 = Norm.Euclidean(a, 0); Assert.IsTrue(expected2.IsEqual(actual2, 0.001f)); float actual3 = Norm.Euclidean(a.GetRow(0)); Assert.AreEqual(21.9634f, actual3, 0.001); }
public static double Distance(List <MDHParameters> dht, double[] target, double[] angles) { var currentPose = GetPositionVector(ForwardKinematics(dht, angles.ToList())); var result = Norm.Euclidean(target.Subtract(currentPose)); return(result); }
public override float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (rows <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "rows"); } if (columns <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "columns"); } if (matrix.Length < rows * columns) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix"); } var work = new float[rows]; return(MatrixNorm(norm, rows, columns, matrix, work)); }
public void EuclideanTest() { double[,] a = { { 15.4457, 0.4187, 15.6093 }, { 0.0000, 2.5708, 0.6534 } }; double[] expected = { 21.9634, 2.6525 }; double[] actual = Norm.Euclidean(a, 1); Assert.IsTrue(expected.IsEqual(actual, 0.001)); double[] expected2 = { 15.4457, 2.6047, 15.6229 }; double[] actual2 = Norm.Euclidean(a, 0); Assert.IsTrue(expected2.IsEqual(actual2, 0.001)); double actual3 = Norm.Euclidean(a.GetRow(0)); Assert.AreEqual(21.9634, actual3, 0.001); }
public override double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (rows <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "rows"); } if (columns <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "columns"); } if (matrix.Length < rows * columns) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix"); } var work = new double[rows]; return SafeNativeMethods.d_matrix_norm((byte)norm, rows, columns, matrix, work); }
public override float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (rows <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "rows"); } if (columns <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "columns"); } if (matrix.Length < rows * columns) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix"); } if (work.Length < rows) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work"); } return(SafeNativeMethods.s_matrix_norm((byte)norm, rows, columns, matrix, work)); }
protected void LoadEntity(Norm entity) { if (entity != null) { #region 中文欄位 EntityId = entity.NormId; Name = entity.Name; SortId = entity.SortId; Status = entity.Status; Content = entity.Content; Pic1 = entity.Pic1; MainCode = entity.MainCode; MainName = entity.MainName; AdminCode = entity.AdminCode; AdminName = entity.AdminName; ServiceCode = entity.ServiceCode; ServiceName = entity.ServiceName; Tag = entity.Tag; if (entity.NormClass != null) { NormClass = entity.NormClass; NormClassId = entity.NormClass.NormClassId; } if (entity.NormClassParent != null) { NormClassParent = entity.NormClassParent; NormClassParentId = entity.NormClassParent.NormClassId; } #endregion } }
public override void CreateEvents() { if (TrainerIndex.IsNull()) { TrainerIndex = Owner.Trainers.Where(g => g.TrainerType == this.TrainerType).Count() + 1; } if (Start != null) { Start.SetDownTick(TickPair.Down); Start.Text = StartText; Start.CreateEvents(); } if (End != null) { End.SetDownTick(TickPair.Up); End.Text = EndText; End.CreateEvents(); } if (this.Loopable) { if (Norm != null) { Norm.SetDownTick(GetNormTick(TickPair)); Norm.Text = NormText; Norm.CreateEvents(); } } base.CreateEvents(); }
private async Task SendToIpcApiAsync(Norm norm) { //var baseurl = @"http://rx-stg.pos.com.my/api/rts/"; //var baseurl = @"http://192.168.1.100:8080/api/rts/"; var baseurl = @"http://172.19.0.111/rest/iism_proxy/"; var client = new HttpClient { BaseAddress = new Uri(baseurl) }; //var ipcuserkey = ConfigurationManager.GetEnvironmentVariable("ipcuserkey"); //client.DefaultRequestHeaders.Add("X-User-Key", ipcuserkey); //var ipcapiurl = ConfigurationManager.GetEnvironmentVariable("Ipc_ApiUrl"); var sb = new StringBuilder(); var fileName = string.Format("sa_deli_{0:yyyyMMdd}_{1:HHmmss}_{2}.txt", norm.Date, norm.Time, norm.ScannerId); var data = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\r\n", norm.CourierId, norm.LocationId, norm.BeatNo, norm.Date.ToString("ddMMyyyy"), norm.Time.ToString("HHmmss"), norm.ConsoleTag, norm.ConsoleInfoType.ToNullStringDash(), norm.OtherConsoleInfo.ToNullStringDash(), norm.NextLocation, norm.Comment.ToNullStringDash(), norm.AllConsignmentNotes, norm.RoutingCode, norm.TotalConsignment); sb.Append(data); var request = new StringContent(sb.ToString()); //request.Headers.ContentType = new MediaTypeHeaderValue("text/plain"); //request.Headers.Add("X-Name", "sa_deli_0100_20180201_182736_14_1209.txt"); //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4iLCJyb2xlcyI6WyJhZG1pbmlzdHJhdG9ycyIsImNhbl9lZGl0X2VudGl0eSIsImNhbl9lZGl0X3dvcmtmbG93IiwiZGV2ZWxvcGVycyJdLCJlbWFpbCI6ImFkbWluQHlvdXJjb21wYW55LmNvbSIsInN1YiI6IjYzNjY3ODk4OTcwMDgwOTk0MjZiNTRlOTRlIiwibmJmIjoxNTQ4MjI0OTcwLCJpYXQiOjE1MzIzMjczNzAsImV4cCI6MTU0NjMwMDgwMCwiYXVkIjoiUG9zRW50dCJ9.pBpQ_JPFi3yso6577r9id0PRtivh1FmkdtZxt_T7j7Y"); //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.PostAsync("saveConsolidationFromRTS", request); var content = await response.Content.ReadAsStringAsync(); }
// can return null if norms aren't stored protected internal virtual byte[] GetNorms(System.String field) { lock (this) { Norm norm = (Norm)norms[field]; if (norm == null) { return(null); // not indexed, or norms not stored } lock (norm) { if (norm.bytes == null) { // value not yet read byte[] bytes = new byte[MaxDoc()]; Norms(field, bytes, 0); norm.bytes = bytes; // cache it // it's OK to close the underlying IndexInput as we have cached the // norms and will never read them again. norm.Close(); } return(norm.bytes); } } }
protected internal override void CommitChanges() { if (deletedDocsDirty) { // re-write deleted si.AdvanceDelGen(); // We can write directly to the actual name (vs to a // .tmp & renaming it) because the file is not live // until segments file is written: deletedDocs.Write(Directory(), si.GetDelFileName()); } if (undeleteAll && si.HasDeletions()) { si.ClearDelGen(); } if (normsDirty) { // re-write norms si.SetNumFields(fieldInfos.Size()); System.Collections.IEnumerator it = norms.Values.GetEnumerator(); while (it.MoveNext()) { Norm norm = (Norm)it.Current; if (norm.dirty) { norm.ReWrite(si); } } } deletedDocsDirty = false; normsDirty = false; undeleteAll = false; }
public override float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (rows <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "rows"); } if (columns <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "columns"); } if (matrix.Length < rows * columns) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix"); } var work = new float[rows]; return MatrixNorm(norm, rows, columns, matrix, work); }
public override void AddToList() { Start.IfObjectNotNull(n => n.AddToList()); End.IfObjectNotNull(n => n.AddToList()); Norm.IfObjectNotNull(n => n.AddToList()); base.AddToList(); }
public void AddNode(Node <T, U> node, double cost) { Nodes.Add(node); if (cost == 1) { } Cost = Norm.Calculate(Cost, cost); }
public override void SetTicks(TickPair ticks) { Start.IfObjectNotNull(n => n.SetDownTick(ticks.Down)); End.IfObjectNotNull(n => n.SetDownTick(ticks.Up)); Norm.IfObjectNotNull(n => n.SetDownTick(GetNormTick(ticks))); base.SetTicks(ticks); }
protected override IQueryOver <EmployeeCard> ItemsQuery(IUnitOfWork uow) { EmployeeProcessingJournalNode resultAlias = null; Post postAlias = null; Subdivision subdivisionAlias = null; EmployeeCard employeeAlias = null; Norm normAlias = null; var employees = uow.Session.QueryOver <EmployeeCard>(() => employeeAlias); if (Filter.ShowOnlyWork) { employees.Where(x => x.DismissDate == null); } if (Filter.Subdivision != null) { employees.Where(x => x.Subdivision.Id == Filter.Subdivision.Id); } if (Filter.Department != null) { employees.Where(x => x.Department.Id == Filter.Department.Id); } var normProjection = CustomProjections.GroupConcat(Projections.SqlFunction("coalesce", NHibernateUtil.String, Projections.Property(() => normAlias.Name), Projections.Property(() => normAlias.Id)), separator: "\n"); return(employees .Where(GetSearchCriterion( () => employeeAlias.Id, () => employeeAlias.CardNumber, () => employeeAlias.PersonnelNumber, () => employeeAlias.LastName, () => employeeAlias.FirstName, () => employeeAlias.Patronymic, () => postAlias.Name, () => subdivisionAlias.Name )) .JoinAlias(() => employeeAlias.Post, () => postAlias, NHibernate.SqlCommand.JoinType.LeftOuterJoin) .JoinAlias(() => employeeAlias.Subdivision, () => subdivisionAlias, NHibernate.SqlCommand.JoinType.LeftOuterJoin) .Left.JoinAlias(() => employeeAlias.UsedNorms, () => normAlias) .SelectList((list) => list .SelectGroup(x => x.Id).WithAlias(() => resultAlias.Id) .Select(x => x.CardNumber).WithAlias(() => resultAlias.CardNumber) .Select(x => x.PersonnelNumber).WithAlias(() => resultAlias.PersonnelNumber) .Select(x => x.FirstName).WithAlias(() => resultAlias.FirstName) .Select(x => x.LastName).WithAlias(() => resultAlias.LastName) .Select(x => x.Patronymic).WithAlias(() => resultAlias.Patronymic) .Select(() => employeeAlias.DismissDate).WithAlias(() => resultAlias.DismissDate) .Select(() => postAlias.Name).WithAlias(() => resultAlias.Post) .Select(() => subdivisionAlias.Name).WithAlias(() => resultAlias.Subdivision) .Select(normProjection).WithAlias(() => resultAlias.Norms) ) .OrderBy(() => employeeAlias.LastName).Asc .ThenBy(() => employeeAlias.FirstName).Asc .ThenBy(() => employeeAlias.Patronymic).Asc .TransformUsing(Transformers.AliasToBean <EmployeeProcessingJournalNode>())); }
/// <summary> /// Computes the variable importance in projection (VIP) /// </summary> /// <returns> /// A predictors x factors matrix in which each row represents /// the importance of the variable in a projection considering /// the number of factors indicated by the column. /// </returns> /// <remarks> /// References: /// - http://mevik.net/work/software/VIP.R /// - http://www.postech.ac.kr/~chjun/publication/Chemometrics/chemo05.pdf /// </remarks> protected double[,] ComputeVariableImportanceInProjection(int factors) { int xcols = sourceX.GetLength(1); double[,] importance = new double[xcols, factors]; // For each input variable for (int j = 0; j < xcols; j++) { double[] SS1 = new double[factors]; double[] SS2 = new double[factors]; // For each latent factor for (int k = 0; k < factors; k++) { // Assume single response variable var b = loadingsY.GetColumn(k)[0]; var t = scoresX.GetColumn(k); var w = loadingsX.GetColumn(k); var ss = (b * b) * (t.InnerProduct(t)); var wn = (w[j] * w[j]) / Norm.SquareEuclidean(w); SS1[k] = ss * wn; SS2[k] = ss; } var sum1 = Matrix.CumulativeSum(SS1); var sum2 = Matrix.CumulativeSum(SS2); for (int k = 0; k < factors; k++) { importance[j, k] = System.Math.Sqrt(xcols * sum1[k] / sum2[k]); } } return(importance); // Matricial form (possibly more efficient) solution /* * var SS = loadingsY.ElementwisePower(2).GetRow(0) * .ElementwiseMultiply(scoresX.ElementwisePower(2).Sum(1)); * * var loadingsX2 = loadingsX.ElementwisePower(2); * * var Wnorm2 = loadingsX2.Sum(1); * * var SSW = loadingsX2.ElementwiseMultiply(SS.ElementwiseDivide(Wnorm2), 1); * * var division = SSW.CumulativeSum(0).ToMatrix() * .ElementwiseDivide(SS.CumulativeSum(), 0); * * this.vip = Matrix.Sqrt(division.Multiply(SSW.GetLength(0))).Transpose(); */ }
public void FrobeniusTest() { double[,] a = Matrix.Magic(5); double expected = 74.330343736592520; double actual = Norm.Frobenius(a); Assert.AreEqual(expected, actual, 1e-12); }
private static void createNorms() { // create list of Norm objects from normsPathList norms = new Norm[normsPathList.Length]; for (int i = 0; i < norms.Length; i++) { norms[i] = new Norm(normsPathList[i]); } //norms = norms.OrderBy(x => x.name).ToList(); }
internal static Norm GetNoOrmInstance(this DbConnection connection) { if (Table.TryGetValue(connection, out var instance)) { return(instance); } instance = new Norm(connection); Table.Add(connection, instance); return(instance); }
private async Task DeleteNormRowAsync(Norm item) { using (var conn = new SqlConnection(ConfigurationManager.GetEnvironmentVariable("OalConnectionString"))) //using (var conn = new SqlConnection(ConfigurationManager.GetEnvironmentVariable("ConnectionString"))) using (SqlCommand cmd = new SqlCommand("DELETE FROM dbo.Norm WHERE Id=@Id", conn)) { cmd.Parameters.Add("@id", SqlDbType.Int, 4).Value = item.id; await conn.OpenAsync().ConfigureAwait(false); } }
public IList <EmployeeCard> GetEmployeesUseNorm(Norm[] norms, IUnitOfWork uow = null) { Norm normAlias = null; return((uow ?? RepoUow).Session.QueryOver <EmployeeCard>() .JoinAlias(x => x.UsedNorms, () => normAlias) .Where(x => normAlias.Id.IsIn(norms.GetIds().ToArray())) .TransformUsing(Transformers.DistinctRootEntity) .List()); }
public void HandleDelete_CanDeleteEmployeeTest() { var ask = Substitute.For <IInteractiveQuestion>(); ask.Question(string.Empty).ReturnsForAnyArgs(true); using (var uow = UnitOfWorkFactory.CreateWithoutRoot("Тест на обработку удаления сотрудника")) { BuisnessLogicGlobalEventHandler.Init(ask, UnitOfWorkFactory); var nomenclatureType = new ItemsType(); nomenclatureType.Name = "Тестовый тип номенклатуры"; uow.Save(nomenclatureType); var nomenclature = new Nomenclature(); nomenclature.Type = nomenclatureType; uow.Save(nomenclature); var protectionTools = new ProtectionTools(); protectionTools.Name = "СИЗ для тестирования"; protectionTools.AddNomeclature(nomenclature); uow.Save(protectionTools); var norm = new Norm(); var normItem = norm.AddItem(protectionTools); normItem.Amount = 1; normItem.NormPeriod = NormPeriodType.Month; normItem.PeriodCount = 2; uow.Save(norm); var employee = new EmployeeCard(); uow.Save(employee); var warehouseOperation = new WarehouseOperation(); var expenseOp = new EmployeeIssueOperation(); expenseOp.OperationTime = warehouseOperation.OperationTime = new DateTime(2019, 1, 1); expenseOp.ExpiryByNorm = new DateTime(2019, 4, 1); expenseOp.ProtectionTools = protectionTools; expenseOp.Employee = employee; expenseOp.Nomenclature = warehouseOperation.Nomenclature = nomenclature; expenseOp.NormItem = normItem; warehouseOperation.Amount = expenseOp.Issued = 1; expenseOp.WarehouseOperation = warehouseOperation; uow.Save(nomenclature); uow.Save(normItem); uow.Save(warehouseOperation); uow.Save(expenseOp); uow.Commit(); //FIXME Временно чтобы переделака не вызвала конфликт мержа в 2.4 Configure.ConfigureDeletion(); var deletion = new DeleteCore(DeleteConfig.Main, uow); deletion.PrepareDeletion(typeof(EmployeeCard), employee.Id, CancellationToken.None); deletion.RunDeletion(CancellationToken.None); } }
/// <summary> /// Initializes a new instance of the LogisticRegression class. /// </summary> /// <param name="penalty">Used to specify the norm used in the penalization.</param> /// <param name="dual"> /// Dual or primal formulation. Dual formulation is only /// implemented for l2 penalty. Prefer dual=false when /// nSamples > nFeatures. /// </param> /// <param name="tol"></param> /// <param name="c">Inverse of regularization strength; must be a positive float. /// Like in support vector machines, smaller values specify stronger /// regularization. /// </param> /// <param name="fitIntercept"> /// Specifies if a constant (a.k.a. bias or intercept) should be /// added the decision function. /// </param> /// <param name="interceptScaling"> /// when fitIntercept is true, instance vector x becomes /// [x, self.intercept_scaling], /// i.e. a "synthetic" feature with constant value equals to /// interceptScaling is appended to the instance vector. /// The intercept becomes intercept_scaling * synthetic feature weight /// Note! the synthetic feature weight is subject to l1/l2 regularization /// as all other features. /// To lessen the effect of regularization on synthetic feature weight /// (and therefore on the intercept) interceptScaling has to be increased /// </param> /// <param name="classWeightEstimator">Set the parameter C of class i to class_weight[i]*C for /// SVC. If not given or ClassWeight.Uniform is used, all classes are supposed to have /// weight one. ClassWeight.Auto uses the values of y to /// automatically adjust weights inversely proportional to class frequencies.</param> /// <param name="random"> /// The seed of the pseudo random number generator to use when /// shuffling the data. /// </param> public LogisticRegression( Norm penalty = Norm.L2, bool dual = false, double tol = 1e-4, double c = 1.0, bool fitIntercept = true, double interceptScaling = 1, ClassWeightEstimator <TLabel> classWeightEstimator = null, Random random = null) : base(fitIntercept, penalty, Loss.LogisticRegression, dual, tol, c, interceptScaling: interceptScaling, random: random, classWeightEstimator: classWeightEstimator) { }
public void CanComputeMatrixNorm(Norm norm, float[] matrix, float[] work) { }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public Complex MatrixNorm(Norm norm, Complex[] matrix) { throw new NotImplementedException(); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/> /// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public double MatrixNorm(Norm norm, double[] matrix, double[] work) { throw new NotImplementedException(); }
// // GET: /Users/Details/5 public ViewResult Details(Norm.ObjectId id) { User user = context.Users.GetAll().Single(x => x.Id == id); return View(user); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows in the matrix.</param> /// <param name="columns">The number of columns in the matrix.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) { throw new NotImplementedException(); }
// // GET: /Games/Edit/5 public ActionResult Edit(Norm.ObjectId id) { Game game = context.Games.GetAll().Single(x => x.Id == id); return View(game); }
public ActionResult DeleteConfirmed(Norm.ObjectId id) { _repository.Remove(id); return RedirectToAction("Index"); }
// // GET: /HashTags/Details/5 public ViewResult Details(Norm.ObjectId id) { HashTag hashtag = _repository.Linq().Single(x => x.Id == id); return View(hashtag); }
// // GET: /HashTags/Edit/5 public ActionResult Edit(Norm.ObjectId id) { HashTag hashtag = _repository.Linq().Single(x => x.Id == id); return View(hashtag); }
public void CanComputeMatrixNorm(Norm norm, double[] matrix, double[] work) { }
public ActionResult DeleteConfirmed(Norm.ObjectId id) { User user = context.Users.GetAll().Single(x => x.Id == id); context.Users.Delete(user); return RedirectToAction("Index"); }
public void DecRef() { lock (this) { System.Diagnostics.Debug.Assert(refCount > 0 &&(origNorm == null || origNorm.refCount > 0)); if (--refCount == 0) { if (origNorm != null) { origNorm.DecRef(); origNorm = null; } else { CloseInput(); } if (bytes != null) { System.Diagnostics.Debug.Assert(bytesRef != null); bytesRef.DecRef(); bytes = null; bytesRef = null; } else { System.Diagnostics.Debug.Assert(bytesRef == null); } } } }
// Load & cache full bytes array. Returns bytes. public byte[] Bytes() { lock (this) { System.Diagnostics.Debug.Assert(refCount > 0 &&(origNorm == null || origNorm.refCount > 0)); if (bytes == null) { // value not yet read System.Diagnostics.Debug.Assert(bytesRef == null); if (origNorm != null) { // Ask origNorm to load so that for a series of // reopened readers we share a single read-only // byte[] bytes = origNorm.Bytes(); bytesRef = origNorm.bytesRef; bytesRef.IncRef(); // Once we've loaded the bytes we no longer need // origNorm: origNorm.DecRef(); origNorm = null; } else { // We are the origNorm, so load the bytes for real // ourself: int count = Enclosing_Instance.MaxDoc(); bytes = new byte[count]; // Since we are orig, in must not be null System.Diagnostics.Debug.Assert(in_Renamed != null); // Read from disk. lock (in_Renamed) { in_Renamed.Seek(normSeek); in_Renamed.ReadBytes(bytes, 0, count, false); } bytesRef = new Ref(); CloseInput(); } } return bytes; } }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) { throw new NotImplementedException(); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) { var ret = 0.0; switch (norm) { case Norm.OneNorm: break; case Norm.LargestAbsoluteValue: break; case Norm.InfinityNorm: break; case Norm.FrobeniusNorm: break; } return ret; }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <param name="work">The work array. Not used in the managed provider.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public virtual double MatrixNorm(Norm norm, int rows, int columns, double[] matrix, double[] work) { return MatrixNorm(norm, rows, columns, matrix); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows in the matrix.</param> /// <param name="columns">The number of columns in the matrix.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public float MatrixNorm(Norm norm, int rows, int columns, float[] matrix) { throw new NotImplementedException(); }
// // GET: /Users/Edit/5 public ActionResult Edit(Norm.ObjectId id) { User user = context.Users.GetAll().Single(x => x.Id == id); return View(user); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public virtual double MatrixNorm(Norm norm, int rows, int columns, double[] matrix) { var ret = 0.0; switch (norm) { case Norm.OneNorm: for (var j = 0; j < columns; j++) { var s = 0.0; for (var i = 0; i < rows; i++) { s += Math.Abs(matrix[(j * rows) + i]); } ret = Math.Max(ret, s); } break; case Norm.LargestAbsoluteValue: for (var i = 0; i < rows; i++) { for (var j = 0; j < columns; j++) { ret = Math.Max(Math.Abs(matrix[(j * rows) + i]), ret); } } break; case Norm.InfinityNorm: for (var i = 0; i < rows; i++) { var s = 0.0; for (var j = 0; j < columns; j++) { s += Math.Abs(matrix[(j * rows) + i]); } ret = Math.Max(ret, s); } break; case Norm.FrobeniusNorm: var aat = new double[rows * rows]; MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.Transpose, 1.0, matrix, rows, columns, matrix, rows, columns, 0.0, aat); for (var i = 0; i < rows; i++) { ret += Math.Abs(aat[(i * rows) + i]); } ret = Math.Sqrt(ret); break; } return ret; }
// // GET: /Games/Details/5 public ViewResult Details(Norm.ObjectId id) { Game game = context.Games.GetAll().Single(x => x.Id == id); return View(game); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public virtual double MatrixNorm(Norm norm, int rows, int columns, float[] matrix) { switch (norm) { case Norm.OneNorm: var norm1 = 0d; for (var j = 0; j < columns; j++) { var s = 0d; for (var i = 0; i < rows; i++) { s += Math.Abs(matrix[(j*rows) + i]); } norm1 = Math.Max(norm1, s); } return norm1; case Norm.LargestAbsoluteValue: var normMax = 0d; for (var j = 0; j < columns; j++) { for (var i = 0; i < rows; i++) { normMax = Math.Max(Math.Abs(matrix[(j * rows) + i]), normMax); } } return normMax; case Norm.InfinityNorm: var r = new double[rows]; for (var j = 0; j < columns; j++) { for (var i = 0; i < rows; i++) { r[i] += Math.Abs(matrix[(j * rows) + i]); } } // TODO: reuse var max = r[0]; for (int i = 0; i < r.Length; i++) { if (r[i] > max) { max = r[i]; } } return max; case Norm.FrobeniusNorm: var aat = new float[rows*rows]; MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.Transpose, 1.0f, matrix, rows, columns, matrix, rows, columns, 0.0f, aat); var normF = 0d; for (var i = 0; i < rows; i++) { normF += Math.Abs(aat[(i * rows) + i]); } return Math.Sqrt(normF); default: throw new NotSupportedException(); } }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/> /// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public virtual float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) { return MatrixNorm(norm, rows, columns, matrix); }
public override float MatrixNorm(Norm norm, int rows, int columns, float[] matrix, float[] work) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (rows <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "rows"); } if (columns <= 0) { throw new ArgumentException(Resources.ArgumentMustBePositive, "columns"); } if (matrix.Length < rows * columns) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix"); } if (work.Length < rows) { throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work"); } return SafeNativeMethods.s_matrix_norm((byte)norm, rows, columns, matrix, work); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public virtual Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix) { var ret = 0.0; switch (norm) { case Norm.OneNorm: for (var j = 0; j < columns; j++) { var s = 0.0; for (var i = 0; i < rows; i++) { s += matrix[(j * rows) + i].Magnitude; } ret = Math.Max(ret, s); } break; case Norm.LargestAbsoluteValue: for (var i = 0; i < rows; i++) { for (var j = 0; j < columns; j++) { ret = Math.Max(matrix[(j * rows) + i].Magnitude, ret); } } break; case Norm.InfinityNorm: for (var i = 0; i < rows; i++) { var s = 0.0; for (var j = 0; j < columns; j++) { s += matrix[(j * rows) + i].Magnitude; } ret = Math.Max(ret, s); } break; case Norm.FrobeniusNorm: var aat = new Complex32[rows * rows]; MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.Transpose, 1.0f, matrix, rows, columns, matrix, rows, columns, 0.0f, aat); for (var i = 0; i < rows; i++) { ret += aat[(i * rows) + i].Magnitude; } ret = Math.Sqrt(ret); break; } return Convert.ToSingle(ret); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/> /// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public float MatrixNorm(Norm norm, float[] matrix, float[] work) { throw new NotImplementedException(); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="rows">The number of rows.</param> /// <param name="columns">The number of columns.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/> /// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public virtual Complex32 MatrixNorm(Norm norm, int rows, int columns, Complex32[] matrix, float[] work) { return MatrixNorm(norm, rows, columns, matrix); }
/// <summary> /// Computes the requested <see cref="Norm"/> of the matrix. /// </summary> /// <param name="norm">The type of norm to compute.</param> /// <param name="matrix">The matrix to compute the norm from.</param> /// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/> /// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param> /// <returns> /// The requested <see cref="Norm"/> of the matrix. /// </returns> public Complex32 MatrixNorm(Norm norm, Complex32[] matrix, Complex32[] work) { throw new NotImplementedException(); }
public SimpleNormForTypesTests() { norm = new Norm(new SimpleAssert(message => new AssertException(message))); }