001/* 002 * $Id: PSUtil.java 4975 2014-10-23 21:03:46Z kredel $ 003 */ 004 005package edu.jas.ps; 006 007 008import java.util.List; 009 010import edu.jas.structure.RingElem; 011import edu.jas.structure.UnaryFunctor; 012import edu.jas.util.ListUtil; 013 014 015/** 016 * Power series utilities. For example monic power series. 017 * @author Heinz Kredel 018 */ 019 020public class PSUtil { 021 022 023 /** 024 * Power series list monic. 025 * @param <C> coefficient type. 026 * @param L list of power series with field coefficients. 027 * @return list of power series with leading coefficient 1. 028 */ 029 public static <C extends RingElem<C>> List<MultiVarPowerSeries<C>> monic(List<MultiVarPowerSeries<C>> L) { 030 return ListUtil.<MultiVarPowerSeries<C>, MultiVarPowerSeries<C>> map(L, 031 new UnaryFunctor<MultiVarPowerSeries<C>, MultiVarPowerSeries<C>>() { 032 033 034 public MultiVarPowerSeries<C> eval(MultiVarPowerSeries<C> c) { 035 if (c == null) { 036 return null; 037 } 038 return c.monic(); 039 } 040 }); 041 } 042 043 044 /** 045 * Univariate power series list monic. 046 * @param <C> coefficient type. 047 * @param L list of univariate power series with field coefficients. 048 * @return list of univariate power series with leading coefficient 1. 049 */ 050 public static <C extends RingElem<C>> List<UnivPowerSeries<C>> monicUniv(List<UnivPowerSeries<C>> L) { 051 return ListUtil.<UnivPowerSeries<C>, UnivPowerSeries<C>> map(L, 052 new UnaryFunctor<UnivPowerSeries<C>, UnivPowerSeries<C>>() { 053 054 055 public UnivPowerSeries<C> eval(UnivPowerSeries<C> c) { 056 if (c == null) { 057 return null; 058 } 059 return c.monic(); 060 } 061 }); 062 } 063 064}