Lines Matching refs:L
47 template <typename L, StringType S = STRING_LEFT>
50 template <typename L, StringType S = STRING_LEFT>
53 template <typename L, StringType S = STRING_LEFT>
56 template <typename L, StringType S>
57 bool operator==(const StringWeight<L, S> &, const StringWeight<L, S> &);
61 template <typename L, StringType S>
64 typedef L Label;
65 typedef StringWeight<L, REVERSE_STRING_TYPE(S)> ReverseWeight;
67 friend class StringWeightIterator<L, S>;
68 friend class StringWeightReverseIterator<L, S>;
69 friend bool operator==<>(const StringWeight<L, S> &,
70 const StringWeight<L, S> &);
81 explicit StringWeight(L l) { Init(); PushBack(l); } in StringWeight()
83 static const StringWeight<L, S> &Zero() { in Zero()
84 static const StringWeight<L, S> zero(kStringInfinity); in Zero()
88 static const StringWeight<L, S> &One() { in One()
89 static const StringWeight<L, S> one; in One()
110 StringWeight<L, S> Quantize(float delta = kDelta) const {
136 void PushFront(L l) { in PushFront()
142 void PushBack(L l) { in PushBack()
150 L first_; // first label in string (0 if empty)
151 list<L> rest_; // remaining labels in string
156 template <typename L, StringType S>
159 explicit StringWeightIterator(const StringWeight<L, S>& w) in StringWeightIterator() argument
168 const L& Value() const { return init_ ? first_ : *iter_; } in Value()
181 const L &first_;
182 const list<L> &rest_;
184 typename list<L>::const_iterator iter_;
191 template <typename L, StringType S>
194 explicit StringWeightReverseIterator(const StringWeight<L, S>& w) in StringWeightReverseIterator() argument
200 const L& Value() const { return iter_ == rest_.rend() ? first_ : *iter_; } in Value()
213 const L &first_;
214 const list<L> &rest_;
216 typename list<L>::const_reverse_iterator iter_;
225 template <typename L, StringType S>
226 inline istream &StringWeight<L, S>::Read(istream &strm) { in Read()
231 L label; in Read()
238 template <typename L, StringType S>
239 inline ostream &StringWeight<L, S>::Write(ostream &strm) const { in Write()
242 for (StringWeightIterator<L, S> iter(*this); !iter.Done(); iter.Next()) { in Write()
243 L label = iter.Value(); in Write()
249 template <typename L, StringType S>
250 inline bool StringWeight<L, S>::Member() const { in Member()
253 StringWeightIterator<L, S> iter(*this); in Member()
257 template <typename L, StringType S>
258 inline typename StringWeight<L, S>::ReverseWeight
259 StringWeight<L, S>::Reverse() const { in Reverse()
261 for (StringWeightIterator<L, S> iter(*this); !iter.Done(); iter.Next()) in Reverse()
266 template <typename L, StringType S>
267 inline ssize_t StringWeight<L, S>::Hash() const { in Hash()
269 for (StringWeightIterator<L, S> iter(*this); !iter.Done(); iter.Next()) in Hash()
287 template <typename L, StringType S>
288 inline bool operator==(const StringWeight<L, S> &w1,
289 const StringWeight<L, S> &w2) {
293 StringWeightIterator<L, S> iter1(w1);
294 StringWeightIterator<L, S> iter2(w2);
303 template <typename L, StringType S>
304 inline bool operator!=(const StringWeight<L, S> &w1,
305 const StringWeight<L, S> &w2) {
309 template <typename L, StringType S>
310 inline bool ApproxEqual(const StringWeight<L, S> &w1,
311 const StringWeight<L, S> &w2,
316 template <typename L, StringType S>
317 inline ostream &operator<<(ostream &strm, const StringWeight<L, S> &w) {
318 StringWeightIterator<L, S> iter(w);
334 template <typename L, StringType S>
335 inline istream &operator>>(istream &strm, StringWeight<L, S> &w) {
339 w = StringWeight<L, S>::Zero();
341 w = StringWeight<L, S>::One();
361 template <typename L, StringType S> inline StringWeight<L, S>
362 Plus(const StringWeight<L, S> &w1, in Plus() argument
363 const StringWeight<L, S> &w2) { in Plus()
364 if (w1 == StringWeight<L, S>::Zero()) in Plus()
366 if (w2 == StringWeight<L, S>::Zero()) in Plus()
378 template <typename L> inline StringWeight<L, STRING_LEFT>
379 Plus(const StringWeight<L, STRING_LEFT> &w1, in Plus() argument
380 const StringWeight<L, STRING_LEFT> &w2) { in Plus()
381 if (w1 == StringWeight<L, STRING_LEFT>::Zero()) in Plus()
383 if (w2 == StringWeight<L, STRING_LEFT>::Zero()) in Plus()
386 StringWeight<L, STRING_LEFT> sum; in Plus()
387 StringWeightIterator<L, STRING_LEFT> iter1(w1); in Plus()
388 StringWeightIterator<L, STRING_LEFT> iter2(w2); in Plus()
397 template <typename L> inline StringWeight<L, STRING_RIGHT>
398 Plus(const StringWeight<L, STRING_RIGHT> &w1, in Plus() argument
399 const StringWeight<L, STRING_RIGHT> &w2) { in Plus()
400 if (w1 == StringWeight<L, STRING_RIGHT>::Zero()) in Plus()
402 if (w2 == StringWeight<L, STRING_RIGHT>::Zero()) in Plus()
405 StringWeight<L, STRING_RIGHT> sum; in Plus()
406 StringWeightReverseIterator<L, STRING_RIGHT> iter1(w1); in Plus()
407 StringWeightReverseIterator<L, STRING_RIGHT> iter2(w2); in Plus()
415 template <typename L, StringType S>
416 inline StringWeight<L, S> Times(const StringWeight<L, S> &w1, in Times() argument
417 const StringWeight<L, S> &w2) { in Times()
418 if (w1 == StringWeight<L, S>::Zero() || w2 == StringWeight<L, S>::Zero()) in Times()
419 return StringWeight<L, S>::Zero(); in Times()
421 StringWeight<L, S> prod(w1); in Times()
422 for (StringWeightIterator<L, S> iter(w2); !iter.Done(); iter.Next()) in Times()
431 template <typename L, StringType S> inline StringWeight<L, S>
432 Divide(const StringWeight<L, S> &w1, in Divide() argument
433 const StringWeight<L, S> &w2, in Divide()
438 << "for the " << StringWeight<L, S>::Type() << " semiring"; in Divide()
440 if (w2 == StringWeight<L, S>::Zero()) in Divide()
441 return StringWeight<L, S>(kStringBad); in Divide()
442 else if (w1 == StringWeight<L, S>::Zero()) in Divide()
443 return StringWeight<L, S>::Zero(); in Divide()
445 StringWeight<L, S> div; in Divide()
446 StringWeightIterator<L, S> iter(w1); in Divide()
456 template <typename L> inline StringWeight<L, STRING_RIGHT>
457 Divide(const StringWeight<L, STRING_RIGHT> &w1, in Divide() argument
458 const StringWeight<L, STRING_RIGHT> &w2, in Divide()
465 if (w2 == StringWeight<L, STRING_RIGHT>::Zero()) in Divide()
466 return StringWeight<L, STRING_RIGHT>(kStringBad); in Divide()
467 else if (w1 == StringWeight<L, STRING_RIGHT>::Zero()) in Divide()
468 return StringWeight<L, STRING_RIGHT>::Zero(); in Divide()
470 StringWeight<L, STRING_RIGHT> div; in Divide()
471 StringWeightReverseIterator<L, STRING_RIGHT> iter(w1); in Divide()
481 template <typename L> inline StringWeight<L, STRING_RIGHT_RESTRICT>
482 Divide(const StringWeight<L, STRING_RIGHT_RESTRICT> &w1, in Divide() argument
483 const StringWeight<L, STRING_RIGHT_RESTRICT> &w2, in Divide()
490 if (w2 == StringWeight<L, STRING_RIGHT_RESTRICT>::Zero()) in Divide()
491 return StringWeight<L, STRING_RIGHT_RESTRICT>(kStringBad); in Divide()
492 else if (w1 == StringWeight<L, STRING_RIGHT_RESTRICT>::Zero()) in Divide()
493 return StringWeight<L, STRING_RIGHT_RESTRICT>::Zero(); in Divide()
495 StringWeight<L, STRING_RIGHT_RESTRICT> div; in Divide()
496 StringWeightReverseIterator<L, STRING_RIGHT_RESTRICT> iter(w1); in Divide()
506 template <class L, class W, StringType S = STRING_LEFT>
507 struct GallicWeight : public ProductWeight<StringWeight<L, S>, W> {
508 typedef GallicWeight<L, typename W::ReverseWeight, REVERSE_STRING_TYPE(S)>
513 GallicWeight(StringWeight<L, S> w1, W w2) in GallicWeight()
514 : ProductWeight<StringWeight<L, S>, W>(w1, w2) {} in GallicWeight()
517 : ProductWeight<StringWeight<L, S>, W>(s, nread) {}
519 GallicWeight(const ProductWeight<StringWeight<L, S>, W> &w) in GallicWeight()
520 : ProductWeight<StringWeight<L, S>, W>(w) {} in GallicWeight()