code
stringlengths
114
1.05M
path
stringlengths
3
312
quality_prob
float64
0.5
0.99
learning_prob
float64
0.2
1
filename
stringlengths
3
168
kind
stringclasses
1 value
package ycsb import ( "context" "fmt" "github.com/magiconair/properties" ) // DBCreator creates a database layer. type DBCreator interface { Create(p *properties.Properties) (DB, error) } // DB is the layer to access the database to be benchmarked. type DB interface { // Close closes the database layer. Close() error // InitThread initializes the state associated to the goroutine worker. // The Returned context will be passed to the following usage. InitThread(ctx context.Context, threadID int, threadCount int) context.Context // CleanupThread cleans up the state when the worker finished. CleanupThread(ctx context.Context) // Read reads a record from the database and returns a map of each field/value pair. // table: The name of the table. // key: The record key of the record to read. // fields: The list of fields to read, nil|empty for reading all. Read(ctx context.Context, table string, key string, fields []string) (map[string][]byte, error) // Scan scans records from the database. // table: The name of the table. // startKey: The first record key to read. // count: The number of records to read. // fields: The list of fields to read, nil|empty for reading all. Scan(ctx context.Context, table string, startKey string, count int, fields []string) ([]map[string][]byte, error) // Update updates a record in the database. Any field/value pairs will be written into the // database or overwritten the existing values with the same field name. // table: The name of the table. // key: The record key of the record to update. // values: A map of field/value pairs to update in the record. Update(ctx context.Context, table string, key string, values map[string][]byte) error // Insert inserts a record in the database. Any field/value pairs will be written into the // database. // table: The name of the table. // key: The record key of the record to insert. // values: A map of field/value pairs to insert in the record. Insert(ctx context.Context, table string, key string, values map[string][]byte) error // Delete deletes a record from the database. // table: The name of the table. // key: The record key of the record to delete. Delete(ctx context.Context, table string, key string) error } type BatchDB interface { // BatchInsert inserts batch records in the database. // table: The name of the table. // keys: The keys of batch records. // values: The values of batch records. BatchInsert(ctx context.Context, table string, keys []string, values []map[string][]byte) error // BatchRead reads records from the database. // table: The name of the table. // keys: The keys of records to read. // fields: The list of fields to read, nil|empty for reading all. BatchRead(ctx context.Context, table string, keys []string, fields []string) ([]map[string][]byte, error) // BatchUpdate updates records in the database. // table: The name of table. // keys: The keys of records to update. // values: The values of records to update. BatchUpdate(ctx context.Context, table string, keys []string, values []map[string][]byte) error // BatchDelete deletes records from the database. // table: The name of the table. // keys: The keys of the records to delete. BatchDelete(ctx context.Context, table string, keys []string) error } // AnalyzeDB is the interface for the DB that can perform an analysis on given table. type AnalyzeDB interface { // Analyze performs a key distribution analysis for the table. // table: The name of the table. Analyze(ctx context.Context, table string) error } var dbCreators = map[string]DBCreator{} // RegisterDBCreator registers a creator for the database func RegisterDBCreator(name string, creator DBCreator) { _, ok := dbCreators[name] if ok { panic(fmt.Sprintf("duplicate register database %s", name)) } dbCreators[name] = creator } // GetDBCreator gets the DBCreator for the database func GetDBCreator(name string) DBCreator { return dbCreators[name] }
pkg/ycsb/db.go
0.58818
0.405007
db.go
starcoder
// A sequence of elements supporting sequential and parallel aggregate // operations. The following example illustrates an aggregate operation using // SEE java/util/function/Consumer.java package spliterator import ( "context" "github.com/searKing/golang/go/util/function/consumer" "github.com/searKing/golang/go/util/object" ) /** * An object for traversing and partitioning elements of a source. The source * of elements covered by a Spliterator could be, for example, an array, a * {@link Collection}, an IO channel, or a generator function. * * <p>A Spliterator may traverse elements individually ({@link * #tryAdvance tryAdvance()}) or sequentially in bulk * ({@link #forEachRemaining forEachRemaining()}). * * <p>A Spliterator may also partition off some of its elements (using * {@link #trySplit}) as another Spliterator, to be used in * possibly-parallel operations. Operations using a Spliterator that * cannot split, or does so in a highly imbalanced or inefficient * manner, are unlikely to benefit from parallelism. Traversal * and splitting exhaust elements; each Spliterator is useful for only a single * bulk computation. * * <p>A Spliterator also reports a set of {@link #characteristics()} of its * structure, source, and elements from among {@link #ORDERED}, * {@link #SpliteratorDISTINCT}, {@link #SORTED}, {@link #SpliteratorSIZED}, {@link #NONNULL}, * {@link #IMMUTABLE}, {@link #CONCURRENT}, and {@link #SUBSIZED}. These may * be employed by Spliterator clients to control, specialize or simplify * computation. For example, a Spliterator for a {@link Collection} would * report {@code SpliteratorSIZED}, a Spliterator for a {@link Set} would report * {@code SpliteratorDISTINCT}, and a Spliterator for a {@link SortedSet} would also * report {@code SORTED}. Characteristics are reported as a simple unioned bit * set. * * Some characteristics additionally constrain method behavior; for example if * {@code ORDERED}, traversal methods must conform to their documented ordering. * New characteristics may be defined in the future, so implementors should not * assign meanings to unlisted values. * * <p><a id="binding">A Spliterator that does not report {@code IMMUTABLE} or * {@code CONCURRENT} is expected to have a documented policy concerning: * when the spliterator <em>binds</em> to the element source; and detection of * structural interference of the element source detected after binding.</a> A * <em>late-binding</em> Spliterator binds to the source of elements at the * point of first traversal, first split, or first query for estimated size, * rather than at the time the Spliterator is created. A Spliterator that is * not <em>late-binding</em> binds to the source of elements at the point of * construction or first invocation of any method. Modifications made to the * source prior to binding are reflected when the Spliterator is traversed. * After binding a Spliterator should, on a best-effort basis, throw * {@link ConcurrentModificationException} if structural interference is * detected. Spliterators that do this are called <em>fail-fast</em>. The * bulk traversal method ({@link #forEachRemaining forEachRemaining()}) of a * Spliterator may optimize traversal and check for structural interference * after all elements have been traversed, rather than checking per-element and * failing immediately. * * <p>Spliterators can provide an estimate of the number of remaining elements * via the {@link #estimateSize} method. Ideally, as reflected in characteristic * {@link #SpliteratorSIZED}, this value corresponds exactly to the number of elements * that would be encountered in a successful traversal. However, even when not * exactly known, an estimated value may still be useful to operations * being performed on the source, such as helping to determine whether it is * preferable to split further or traverse the remaining elements sequentially. * * <p>Despite their obvious utility in parallel algorithms, spliterators are not * expected to be thread-safe; instead, implementations of parallel algorithms * using spliterators should ensure that the spliterator is only used by one * thread at a time. This is generally easy to attain via <em>serial * thread-confinement</em>, which often is a natural consequence of typical * parallel algorithms that work by recursive decomposition. A thread calling * {@link #trySplit()} may hand over the returned Spliterator to another thread, * which in turn may traverse or further split that Spliterator. The behaviour * of splitting and traversal is undefined if two or more threads operate * concurrently on the same spliterator. If the original thread hands a * spliterator off to another thread for processing, it is best if that handoff * occurs before any elements are consumed with {@link #tryAdvance(Consumer) * tryAdvance()}, as certain guarantees (such as the accuracy of * {@link #estimateSize()} for {@code SpliteratorSIZED} spliterators) are only valid before * traversal has begun. * * <p>Primitive subtype specializations of {@code Spliterator} are provided for * {@link OfInt int}, {@link OfLong long}, and {@link OfDouble double} values. * The subtype default implementations of * {@link Spliterator#tryAdvance(java.util.function.Consumer)} * and {@link Spliterator#forEachRemaining(java.util.function.Consumer)} box * primitive values to instances of their corresponding wrapper class. Such * boxing may undermine any performance advantages gained by using the primitive * specializations. To avoid boxing, the corresponding primitive-based methods * should be used. For example, * {@link Spliterator.OfInt#tryAdvance(java.util.function.IntConsumer)} * and {@link Spliterator.OfInt#forEachRemaining(java.util.function.IntConsumer)} * should be used in preference to * {@link Spliterator.OfInt#tryAdvance(java.util.function.Consumer)} and * {@link Spliterator.OfInt#forEachRemaining(java.util.function.Consumer)}. * Traversal of primitive values using boxing-based methods * {@link #tryAdvance tryAdvance()} and * {@link #forEachRemaining(java.util.function.Consumer) forEachRemaining()} * does not affect the order in which the values, transformed to boxed values, * are encountered. * * @apiNote * <p>Spliterators, like {@code Iterator}s, are for traversing the elements of * a source. The {@code Spliterator} API was designed to support efficient * parallel traversal in addition to sequential traversal, by supporting * decomposition as well as single-element iteration. In addition, the * protocol for accessing elements via a Spliterator is designed to impose * smaller per-element overhead than {@code Iterator}, and to avoid the inherent * race involved in having separate methods for {@code hasNext()} and * {@code next()}. * * <p>For mutable sources, arbitrary and non-deterministic behavior may occur if * the source is structurally interfered with (elements added, replaced, or * removed) between the time that the Spliterator binds to its data source and * the end of traversal. For example, such interference will produce arbitrary, * non-deterministic results when using the {@code java.util.stream} framework. * * <p>Structural interference of a source can be managed in the following ways * (in approximate order of decreasing desirability): * <ul> * <li>The source cannot be structurally interfered with. * <br>For example, an instance of * {@link java.util.concurrent.CopyOnWriteArrayList} is an immutable source. * A Spliterator created from the source reports a characteristic of * {@code IMMUTABLE}.</li> * <li>The source manages concurrent modifications. * <br>For example, a key set of a {@link java.util.concurrent.ConcurrentHashMap} * is a concurrent source. A Spliterator created from the source reports a * characteristic of {@code CONCURRENT}.</li> * <li>The mutable source provides a late-binding and fail-fast Spliterator. * <br>Late binding narrows the window during which interference can affect * the calculation; fail-fast detects, on a best-effort basis, that structural * interference has occurred after traversal has commenced and throws * {@link ConcurrentModificationException}. For example, {@link ArrayList}, * and many other non-concurrent {@code Collection} classes in the JDK, provide * a late-binding, fail-fast spliterator.</li> * <li>The mutable source provides a non-late-binding but fail-fast Spliterator. * <br>The source increases the likelihood of throwing * {@code ConcurrentModificationException} since the window of potential * interference is larger.</li> * <li>The mutable source provides a late-binding and non-fail-fast Spliterator. * <br>The source risks arbitrary, non-deterministic behavior after traversal * has commenced since interference is not detected. * </li> * <li>The mutable source provides a non-late-binding and non-fail-fast * Spliterator. * <br>The source increases the risk of arbitrary, non-deterministic behavior * since non-detected interference may occur after construction. * </li> * </ul> * * <p><b>Example.</b> Here is a class (not a very useful one, except * for illustration) that maintains an array in which the actual data * are held in even locations, and unrelated tag data are held in odd * locations. Its Spliterator ignores the tags. * * <pre> {@code * class TaggedArray<T> { * private final Object[] elements; // immutable after construction * TaggedArray(T[] data, Object[] tags) { * int size = data.length; * if (tags.length != size) throw new IllegalArgumentException(); * this.elements = new Object[2 * size]; * for (int i = 0, j = 0; i < size; ++i) { * elements[j++] = data[i]; * elements[j++] = tags[i]; * } * } * * public Spliterator<T> spliterator() { * return new TaggedArraySpliterator<>(elements, 0, elements.length); * } * * static class TaggedArraySpliterator<T> implements Spliterator<T> { * private final Object[] array; * private int origin; // current index, advanced on split or traversal * private final int fence; // one past the greatest index * * TaggedArraySpliterator(Object[] array, int origin, int fence) { * this.array = array; this.origin = origin; this.fence = fence; * } * * public void forEachRemaining(Consumer<? super T> action) { * for (; origin < fence; origin += 2) * action.accept((T) array[origin]); * } * * public boolean tryAdvance(Consumer<? super T> action) { * if (origin < fence) { * action.accept((T) array[origin]); * origin += 2; * return true; * } * else // cannot advance * return false; * } * * public Spliterator<T> trySplit() { * int lo = origin; // divide range in half * int mid = ((lo + fence) >>> 1) & ~1; // force midpoint to be even * if (lo < mid) { // split out left half * origin = mid; // reset this Spliterator's origin * return new TaggedArraySpliterator<>(array, lo, mid); * } * else // too small to split * return null; * } * * public long estimateSize() { * return (long)((fence - origin) / 2); * } * * public int characteristics() { * return ORDERED | SpliteratorSIZED | IMMUTABLE | SUBSIZED; * } * } * }}</pre> * * <p>As an example how a parallel computation framework, such as the * {@code java.util.stream} package, would use Spliterator in a parallel * computation, here is one way to implement an associated parallel forEach, * that illustrates the primary usage idiom of splitting off subtasks until * the estimated amount of work is small enough to perform * sequentially. Here we assume that the order of processing across * subtasks doesn't matter; different (forked) tasks may further split * and process elements concurrently in undetermined order. This * example uses a {@link java.util.concurrent.CountedCompleter}; * similar usages apply to other parallel task constructions. * * <pre>{@code * static <T> void parEach(TaggedArray<T> a, Consumer<T> action) { * Spliterator<T> s = a.spliterator(); * long targetBatchSize = s.estimateSize() / (ForkJoinPool.getCommonPoolParallelism() * 8); * new ParEach(null, s, action, targetBatchSize).invoke(); * } * * static class ParEach<T> extends CountedCompleter<Void> { * final Spliterator<T> spliterator; * final Consumer<T> action; * final long targetBatchSize; * * ParEach(ParEach<T> parent, Spliterator<T> spliterator, * Consumer<T> action, long targetBatchSize) { * super(parent); * this.spliterator = spliterator; this.action = action; * this.targetBatchSize = targetBatchSize; * } * * public void compute() { * Spliterator<T> sub; * while (spliterator.estimateSize() > targetBatchSize && * (sub = spliterator.trySplit()) != null) { * addToPendingCount(1); * new ParEach<>(this, sub, action, targetBatchSize).fork(); * } * spliterator.forEachRemaining(action); * propagateCompletion(); * } * }}</pre> * * @implNote * If the boolean system property {@code org.openjdk.java.util.stream.tripwire} * is set to {@code true} then diagnostic warnings are reported if boxing of * primitive values occur when operating on primitive subtype specializations. * * @param <T> the type of elements returned by this Spliterator * * @see Collection * @since 1.8 */ type Spliterator interface { /** * If a remaining element exists, performs the given action on it, * returning {@code true}; else returns {@code false}. If this * Spliterator is {@link #ORDERED} the action is performed on the * next element in encounter order. Exceptions thrown by the * action are relayed to the caller. * * @param action The action * @return {@code false} if no remaining elements existed * upon entry to this method, else {@code true}. * @throws NullPointerException if the specified action is null */ TryAdvance(ctx context.Context, consumer consumer.Consumer) bool /** * Performs the given action for each remaining element, sequentially in * the current thread, until all elements have been processed or the action * throws an exception. If this Spliterator is {@link #ORDERED}, actions * are performed in encounter order. Exceptions thrown by the action * are relayed to the caller. * * @implSpec * The default implementation repeatedly invokes {@link #tryAdvance} until * it returns {@code false}. It should be overridden whenever possible. * * @param action The action * @throws NullPointerException if the specified action is null */ ForEachRemaining(ctx context.Context, consumer consumer.Consumer) /** * If this spliterator can be partitioned, returns a Spliterator * covering elements, that will, upon return from this method, not * be covered by this Spliterator. * * <p>If this Spliterator is {@link #ORDERED}, the returned Spliterator * must cover a strict prefix of the elements. * * <p>Unless this Spliterator covers an infinite number of elements, * repeated calls to {@code trySplit()} must eventually return {@code null}. * Upon non-null return: * <ul> * <li>the value reported for {@code estimateSize()} before splitting, * must, after splitting, be greater than or equal to {@code estimateSize()} * for this and the returned Spliterator; and</li> * <li>if this Spliterator is {@code SUBSIZED}, then {@code estimateSize()} * for this spliterator before splitting must be equal to the sum of * {@code estimateSize()} for this and the returned Spliterator after * splitting.</li> * </ul> * * <p>This method may return {@code null} for any reason, * including emptiness, inability to split after traversal has * commenced, data structure constraints, and efficiency * considerations. * * @apiNote * An ideal {@code trySplit} method efficiently (without * traversal) divides its elements exactly in half, allowing * balanced parallel computation. Many departures from this ideal * remain highly effective; for example, only approximately * splitting an approximately balanced tree, or for a tree in * which leaf nodes may contain either one or two elements, * failing to further split these nodes. However, large * deviations in balance and/or overly inefficient {@code * trySplit} mechanics typically result in poor parallel * performance. * * @return a {@code Spliterator} covering some portion of the * elements, or {@code null} if this spliterator cannot be split */ TrySplit() Spliterator /** * Returns an estimate of the number of elements that would be * encountered by a {@link #forEachRemaining} traversal, or returns {@link * Long#MAX_VALUE} if infinite, unknown, or too expensive to compute. * * <p>If this Spliterator is {@link #SpliteratorSIZED} and has not yet been partially * traversed or split, or this Spliterator is {@link #SUBSIZED} and has * not yet been partially traversed, this estimate must be an accurate * count of elements that would be encountered by a complete traversal. * Otherwise, this estimate may be arbitrarily inaccurate, but must decrease * as specified across invocations of {@link #trySplit}. * * @apiNote * Even an inexact estimate is often useful and inexpensive to compute. * For example, a sub-spliterator of an approximately balanced binary tree * may return a value that estimates the number of elements to be half of * that of its parent; if the root Spliterator does not maintain an * accurate count, it could estimate size to be the power of two * corresponding to its maximum depth. * * @return the estimated size, or {@code Long.MAX_VALUE} if infinite, * unknown, or too expensive to compute. */ EstimateSize() int /** * Convenience method that returns {@link #estimateSize()} if this * Spliterator is {@link #SpliteratorSIZED}, else {@code -1}. * @implSpec * The default implementation returns the result of {@code estimateSize()} * if the Spliterator reports a characteristic of {@code SpliteratorSIZED}, and * {@code -1} otherwise. * * @return the exact size, if known, else {@code -1}. */ GetExactSizeIfKnown() int /** * Returns a set of characteristics of this Spliterator and its * elements. The result is represented as ORed values from {@link * #ORDERED}, {@link #SpliteratorDISTINCT}, {@link #SORTED}, {@link #SpliteratorSIZED}, * {@link #NONNULL}, {@link #IMMUTABLE}, {@link #CONCURRENT}, * {@link #SUBSIZED}. Repeated calls to {@code characteristics()} on * a given spliterator, prior to or in-between calls to {@code trySplit}, * should always return the same result. * * <p>If a Spliterator reports an inconsistent set of * characteristics (either those returned from a single invocation * or across multiple invocations), no guarantees can be made * about any computation using this Spliterator. * * @apiNote The characteristics of a given spliterator before splitting * may differ from the characteristics after splitting. For specific * examples see the characteristic values {@link #SpliteratorSIZED}, {@link #SUBSIZED} * and {@link #CONCURRENT}. * * @return a representation of characteristics */ Characteristics() Characteristic /** * Returns {@code true} if this Spliterator's {@link * #characteristics} contain all of the given characteristics. * * @implSpec * The default implementation returns true if the corresponding bits * of the given characteristics are set. * * @param characteristics the characteristics to check for * @return {@code true} if all the specified characteristics are present, * else {@code false} */ HasCharacteristics(characteristics Characteristic) bool /** * If this Spliterator's source is {@link #SORTED} by a {@link Comparator}, * returns that {@code Comparator}. If the source is {@code SORTED} in * {@linkplain Comparable natural order}, returns {@code null}. Otherwise, * if the source is not {@code SORTED}, throws {@link IllegalStateException}. * * @implSpec * The default implementation always throws {@link IllegalStateException}. * * @return a Comparator, or {@code null} if the elements are sorted in the * natural order. * @throws IllegalStateException if the spliterator does not report * a characteristic of {@code SORTED}. */ GetComparator() object.Comparator }
go/util/spliterator/spliterator.go
0.891221
0.605974
spliterator.go
starcoder
package missing_authentication import ( "github.com/threagile/threagile/model" ) func Category() model.RiskCategory { return model.RiskCategory{ Id: "missing-authentication", Title: "Missing Authentication", Description: "Technical assets (especially multi-tenant systems) should authenticate incoming requests when the asset processes or stores sensitive data. ", Impact: "If this risk is unmitigated, attackers might be able to access or modify sensitive data in an unauthenticated way.", ASVS: "V2 - Authentication Verification Requirements", CheatSheet: "https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html", Action: "Authentication of Incoming Requests", Mitigation: "Apply an authentication method to the technical asset. To protect highly sensitive data consider " + "the use of two-factor authentication for human users.", Check: "Are recommendations from the linked cheat sheet and referenced ASVS chapter applied?", Function: model.Architecture, STRIDE: model.ElevationOfPrivilege, DetectionLogic: "In-scope technical assets (except " + model.LoadBalancer.String() + ", " + model.ReverseProxy.String() + ", " + model.ServiceRegistry.String() + ", " + model.WAF.String() + ", " + model.IDS.String() + ", and " + model.IPS.String() + " and in-process calls) should authenticate incoming requests when the asset processes or stores " + "sensitive data. This is especially the case for all multi-tenant assets (there even non-sensitive ones).", RiskAssessment: "The risk rating (medium or high) " + "depends on the sensitivity of the data sent across the communication link. Monitoring callers are exempted from this risk.", FalsePositives: "Technical assets which do not process requests regarding functionality or data linked to end-users (customers) " + "can be considered as false positives after individual review.", ModelFailurePossibleReason: false, CWE: 306, } } func SupportedTags() []string { return []string{} } func GenerateRisks() []model.Risk { risks := make([]model.Risk, 0) for _, id := range model.SortedTechnicalAssetIDs() { technicalAsset := model.ParsedModelRoot.TechnicalAssets[id] if technicalAsset.OutOfScope || technicalAsset.Technology == model.LoadBalancer || technicalAsset.Technology == model.ReverseProxy || technicalAsset.Technology == model.ServiceRegistry || technicalAsset.Technology == model.WAF || technicalAsset.Technology == model.IDS || technicalAsset.Technology == model.IPS { continue } if technicalAsset.HighestConfidentiality() >= model.Confidential || technicalAsset.HighestIntegrity() >= model.Critical || technicalAsset.HighestAvailability() >= model.Critical || technicalAsset.MultiTenant { // check each incoming data flow commLinks := model.IncomingTechnicalCommunicationLinksMappedByTargetId[technicalAsset.Id] for _, commLink := range commLinks { caller := model.ParsedModelRoot.TechnicalAssets[commLink.SourceId] if caller.Technology.IsUnprotectedCommsTolerated() || caller.Type == model.Datastore { continue } highRisk := commLink.HighestConfidentiality() == model.StrictlyConfidential || commLink.HighestIntegrity() == model.MissionCritical lowRisk := commLink.HighestConfidentiality() <= model.Internal && commLink.HighestIntegrity() == model.Operational impact := model.MediumImpact if highRisk { impact = model.HighImpact } else if lowRisk { impact = model.LowImpact } if commLink.Authentication == model.NoneAuthentication && !commLink.Protocol.IsProcessLocal() { risks = append(risks, CreateRisk(technicalAsset, commLink, commLink, "", impact, model.Likely, false, Category())) } } } } return risks } func CreateRisk(technicalAsset model.TechnicalAsset, incomingAccess, incomingAccessOrigin model.CommunicationLink, hopBetween string, impact model.RiskExploitationImpact, likelihood model.RiskExploitationLikelihood, twoFactor bool, category model.RiskCategory) model.Risk { factorString := "" if twoFactor { factorString = "Two-Factor " } if len(hopBetween) > 0 { hopBetween = "forwarded via <b>" + hopBetween + "</b> " } risk := model.Risk{ Category: category, Severity: model.CalculateSeverity(likelihood, impact), ExploitationLikelihood: likelihood, ExploitationImpact: impact, Title: "<b>Missing " + factorString + "Authentication</b> covering communication link <b>" + incomingAccess.Title + "</b> " + "from <b>" + model.ParsedModelRoot.TechnicalAssets[incomingAccessOrigin.SourceId].Title + "</b> " + hopBetween + "to <b>" + technicalAsset.Title + "</b>", MostRelevantTechnicalAssetId: technicalAsset.Id, MostRelevantCommunicationLinkId: incomingAccess.Id, DataBreachProbability: model.Possible, DataBreachTechnicalAssetIDs: []string{technicalAsset.Id}, } risk.SyntheticId = risk.Category.Id + "@" + incomingAccess.Id + "@" + model.ParsedModelRoot.TechnicalAssets[incomingAccess.SourceId].Id + "@" + technicalAsset.Id return risk }
risks/built-in/missing-authentication/missing-authentication-rule.go
0.663124
0.426262
missing-authentication-rule.go
starcoder
Package admission provides functions to manage webhooks certificates. There are 3 typical ways to use this library: * The sync function can be used as a Reconcile function. * Invoking it directly fromt eh webhook server at startup. * Deploying it as an init container along with the webhook server. Webhook Configuration The following is an example MutatingWebhookConfiguration in yaml. apiVersion: admissionregistration.k8s.io/v1beta1 kind: MutatingWebhookConfiguration metadata: name: myMutatingWebhookConfiguration annotations: secret.certprovisioner.kubernetes.io/webhook-1: namespace-bar/secret-foo secret.certprovisioner.kubernetes.io/webhook-2: default/secret-baz webhooks: - name: webhook-1 rules: - apiGroups: - "" apiVersions: - v1 operations: - "*" resources: - pods clientConfig: service: namespace: service-ns-1 name: service-foo path: "/mutating-pods" caBundle: [] # CA bundle here - name: webhook-2 rules: - apiGroups: - apps apiVersions: - v1 operations: - "*" resources: - deployments clientConfig: service: namespace: service-ns-2 name: service-bar path: "/mutating-deployment" caBundle: [] # CA bundle here Build the CertProvisioner You can choose to provide your own CertGenerator and CertWriter. An easier way is to use an empty Options the package will default it with reasonable values. The package will write self-signed certificates to secrets. // Build a client. You can also create a client with your own config.Config. cl, err := client.New(config.GetConfigOrDie(), client.Options) if err != nil { // handle error } // Build a CertProvisioner with unspecified CertGenerator and CertWriter. cp := &CertProvisioner{client: cl} Provision certificates Provision certificates for webhook configuration objects' by calling Sync method. err = cp.Sync(mwc) if err != nil { // handler error } When the above MutatingWebhookConfiguration is processed, the cert provisioner will create the certificate and create a secret named "secret-foo" in namespace "namespace-bar" for webhook "webhook-1". Similarly, it will create an secret named "secret-baz" in namespace "default" for webhook "webhook-2". And it will also write the CA back to the WebhookConfiguration. */ package admission
examples/godocbot/vendor/sigs.k8s.io/controller-runtime/pkg/admission/doc.go
0.573081
0.464659
doc.go
starcoder
package main import "fmt" // A wire is modeled as a channel of booleans. // You can feed it a single value without blocking. // Reading a value blocks until a value is available. type Wire chan bool func MkWire() Wire { return make(Wire, 1) } // A source for zero values. func Zero() (r Wire) { r = MkWire() go func() { for { r <- false } }() return } // And gate. func And(a, b Wire) (r Wire) { r = MkWire() go func() { for { r <- (<-a && <-b) } }() return } // Or gate. func Or(a, b Wire) (r Wire) { r = MkWire() go func() { for { r <- (<-a || <-b) } }() return } // Not gate. func Not(a Wire) (r Wire) { r = MkWire() go func() { for { r <- !(<-a) } }() return } // Split a wire in two. func Split(a Wire) (Wire, Wire) { r1 := MkWire() r2 := MkWire() go func() { for { x := <-a r1 <- x r2 <- x } }() return r1, r2 } // Xor gate, composed of Or, And and Not gates. func Xor(a, b Wire) Wire { a1, a2 := Split(a) b1, b2 := Split(b) return Or(And(Not(a1), b1), And(a2, Not(b2))) } // A half adder, composed of two splits and an And and Xor gate. func HalfAdder(a, b Wire) (sum, carry Wire) { a1, a2 := Split(a) b1, b2 := Split(b) carry = And(a1, b1) sum = Xor(a2, b2) return } // A full adder, composed of two half adders, and an Or gate. func FullAdder(a, b, carryIn Wire) (result, carryOut Wire) { s1, c1 := HalfAdder(carryIn, a) result, c2 := HalfAdder(b, s1) carryOut = Or(c1, c2) return } // A four bit adder, composed of a zero source, and four full adders. func FourBitAdder(a1, a2, a3, a4 Wire, b1, b2, b3, b4 Wire) (r1, r2, r3, r4 Wire, carry Wire) { carry = Zero() r1, carry = FullAdder(a1, b1, carry) r2, carry = FullAdder(a2, b2, carry) r3, carry = FullAdder(a3, b3, carry) r4, carry = FullAdder(a4, b4, carry) return } func main() { // Create wires a1, a2, a3, a4 := MakeWire(), MakeWire(), MakeWire(), MakeWire() b1, b2, b3, b4 := MakeWire(), MakeWire(), MakeWire(), MakeWire() // Construct circuit r1, r2, r3, r4, carry := FourBitAdder(a1, a2, a3, a4, b1, b2, b3, b4) // Feed it some values a4 <- false a3 <- false a2 <- true a1 <- false // 0010 b4 <- true b3 <- true b2 <- true b1 <- false // 1110 B := map[bool]int{false: 0, true: 1} // Read the result fmt.Printf("0010 + 1110 = %d%d%d%d (carry = %d)\n", B[<-r4], B[<-r3], B[<-r2], B[<-r1], B[<-carry]) } //\Four-bit-adder\four-bit-adder-2.go
tasks/Four-bit-adder/four-bit-adder-2.go
0.721449
0.611295
four-bit-adder-2.go
starcoder
package linode import ( "context" "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/linode/linodego" ) func dataSourceLinodeInstanceType() *schema.Resource { return &schema.Resource{ Read: dataSourceLinodeInstanceTypeRead, Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, Required: true, }, "label": { Type: schema.TypeString, Optional: true, Description: "The Linode Type's label is for display purposes only.", Computed: true, }, "disk": { Type: schema.TypeInt, Description: "The Disk size, in MB, of the Linode Type.", Computed: true, }, "class": { Type: schema.TypeString, Description: "The class of the Linode Type. There are currently three classes of Linodes: nanode, standard, highmem, dedicated", Computed: true, }, "price": { Type: schema.TypeList, Description: "Cost in US dollars, broken down into hourly and monthly charges.", Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "hourly": { Type: schema.TypeFloat, Description: "Cost (in US dollars) per hour.", Computed: true, }, "monthly": { Type: schema.TypeFloat, Description: "Cost (in US dollars) per month.", Computed: true, }, }, }, }, "addons": { Type: schema.TypeList, Description: "", Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "backups": { Type: schema.TypeList, Description: "Information about the optional Backup service offered for Linodes.", Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "price": { Type: schema.TypeList, Description: "Cost of enabling Backups for this Linode Type.", Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "hourly": { Type: schema.TypeFloat, Description: "The cost (in US dollars) per hour to add Backups service.", Computed: true, }, "monthly": { Type: schema.TypeFloat, Description: "The cost (in US dollars) per month to add Backups service.", Computed: true, }, }, }, }, }, }, }, }, }, }, "network_out": { Type: schema.TypeInt, Description: "The Mbits outbound bandwidth allocation.", Computed: true, }, "memory": { Type: schema.TypeInt, Description: "Amount of RAM included in this Linode Type.", Computed: true, }, "transfer": { Type: schema.TypeInt, Description: "The monthly outbound transfer amount, in MB.", Computed: true, }, "vcpus": { Type: schema.TypeInt, Description: "The number of VCPU cores this Linode Type offers.", Computed: true, }, }, } } func dataSourceLinodeInstanceTypeRead(d *schema.ResourceData, meta interface{}) error { client := meta.(linodego.Client) types, err := client.ListTypes(context.Background(), nil) if err != nil { return fmt.Errorf("Error listing ranges: %s", err) } reqType := d.Get("id").(string) for _, r := range types { if r.ID == reqType { d.SetId(r.ID) d.Set("label", r.Label) d.Set("disk", r.Disk) d.Set("memory", r.Memory) d.Set("vcpus", r.VCPUs) d.Set("network_out", r.NetworkOut) d.Set("transfer", r.Transfer) d.Set("class", r.Class) d.Set("price", []map[string]interface{}{{ "hourly": r.Price.Hourly, "monthly": r.Price.Monthly, }}) d.Set("addons", []map[string]interface{}{{ "backups": []map[string]interface{}{{ "price": []map[string]interface{}{{ "hourly": r.Addons.Backups.Price.Hourly, "monthly": r.Addons.Backups.Price.Monthly, }}, }}, }}) return nil } } d.SetId("") return fmt.Errorf("Instance Type %s was not found", reqType) }
vendor/github.com/terraform-providers/terraform-provider-linode/linode/data_source_linode_instance_type.go
0.536313
0.407628
data_source_linode_instance_type.go
starcoder
package basic // MergeTestPtr is template to generate itself for different combination of data type. func MergeTestPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v1 <INPUT_TYPE1> = 1 var v2 <INPUT_TYPE1> = 2 var v3 <INPUT_TYPE1> = 3 var v4 <INPUT_TYPE1> = 4 var v5 <INPUT_TYPE1> = 5 var v10 <INPUT_TYPE2> = 10 var v20 <INPUT_TYPE2> = 20 var v30 <INPUT_TYPE2> = 30 var v40 <INPUT_TYPE2> = 40 var v50 <INPUT_TYPE2> = 50 map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &v10, &v2: &v20, &v3: &v30} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &v10, &v2: &v20, &v4: &v40, &v5: &v50, &v3: &v30} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2> failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestNumbersToStringPtr is template to generate itself for different combination of data type. func MergeTestNumbersToStringPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v1 <INPUT_TYPE1> = 1 var v2 <INPUT_TYPE1> = 2 var v3 <INPUT_TYPE1> = 3 var v4 <INPUT_TYPE1> = 4 var v5 <INPUT_TYPE1> = 5 var v10 <INPUT_TYPE2> = "10" var v20 <INPUT_TYPE2> = "20" var v30 <INPUT_TYPE2> = "30" var v40 <INPUT_TYPE2> = "40" var v50 <INPUT_TYPE2> = "50" map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &v10, &v2: &v20, &v3: &v30} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &v10, &v2: &v20, &v4: &v40, &v5: &v50, &v3: &v30} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestStringToNumbersPtr is template to generate itself for different combination of data type. func MergeTestStringToNumbersPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v1 <INPUT_TYPE1> = "1" var v2 <INPUT_TYPE1> = "2" var v3 <INPUT_TYPE1> = "3" var v4 <INPUT_TYPE1> = "4" var v5 <INPUT_TYPE1> = "5" var v10 <INPUT_TYPE2> = 10 var v20 <INPUT_TYPE2> = 20 var v30 <INPUT_TYPE2> = 30 var v40 <INPUT_TYPE2> = 40 var v50 <INPUT_TYPE2> = 50 map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &v10, &v2: &v20, &v3: &v30} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &v10, &v2: &v20, &v4: &v40, &v5: &v50, &v3: &v30} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1>Ptr<FINPUT_TYPE2> failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &v40, &v5: &v50, &v3: &v30} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestStringToBoolPtr is template to generate itself for different combination of data type. func MergeTestStringToBoolPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v0 <INPUT_TYPE1> = "0" var v1 <INPUT_TYPE1> = "1" var v3 <INPUT_TYPE1> = "3" var v4 <INPUT_TYPE1> = "4" var v5 <INPUT_TYPE1> = "5" var vt <INPUT_TYPE2> = true var vf <INPUT_TYPE2> = false map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vt, &v0: &vf, &v3: &vt} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vt, &v0: &vf, &v4: &vt, &v5: &vt, &v3: &vt} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if *expected[&v0] != *actual[&v0] { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", *expected[&v0], *actual[&v0]) } if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestBoolToStringPtr is template to generate itself for different combination of data type. func MergeTestBoolToStringPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v0 <INPUT_TYPE2> = "0" var v1 <INPUT_TYPE2> = "1" var v2 <INPUT_TYPE2> = "2" var vt <INPUT_TYPE1> = true var vf <INPUT_TYPE1> = false map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v2} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v2, &vf: &v0} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestNumberToBoolPtr is template to generate itself for different combination of data type. func MergeTestNumberToBoolPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v0 <INPUT_TYPE1> = 0 var v1 <INPUT_TYPE1> = 1 var v3 <INPUT_TYPE1> = 3 var v4 <INPUT_TYPE1> = 4 var v5 <INPUT_TYPE1> = 5 var vt <INPUT_TYPE2> = true var vf <INPUT_TYPE2> = false map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vt, &v0: &vf, &v3: &vt} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vf, &v3: &vt} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vt, &v0: &vf, &v4: &vt, &v5: &vf, &v3: &vt} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v4: &vt, &v5: &vt, &v3: &vt} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestBoolToNumberPtr is template to generate itself for different combination of data type. func MergeTestBoolToNumberPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var vt <INPUT_TYPE1> = true var vf <INPUT_TYPE1> = false var v1 <INPUT_TYPE2> = 1 var v0 <INPUT_TYPE2> = 2 map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &v1, &vf: &v0} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestBoolToBoolPtr is template to generate itself for different combination of data type. func MergeTestBoolToBoolPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var vt bool = true var vf bool = false map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&vt: &vt, &vf: &vf} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` } // MergeTestStrToStrPtr is template to generate itself for different combination of data type. func MergeTestStrToStrPtr() string { return ` func TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(t *testing.T) { var v1 <INPUT_TYPE1> = 1 var v2 <INPUT_TYPE1> = 2 var vOne <INPUT_TYPE2> = "One" var vTwo <INPUT_TYPE2> = "Two" map1 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} map2 := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v2: &vTwo} expected := map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} actual := Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = nil map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} map2 = nil expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } map1 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} map2 = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{} expected = map[*<INPUT_TYPE1>]*<INPUT_TYPE2>{&v1: &vOne, &v2: &vTwo} actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(map1, map2) if !reflect.DeepEqual(expected, actual) { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=%v, actual=%v", expected, actual) } actual = Merge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr(nil, nil) if len(actual) != 0 { t.Errorf("TestMerge<FINPUT_TYPE1><FINPUT_TYPE2>Ptr failed. Expected=empty mape, actual=%v", actual) } } ` }
internal/template/basic/mergeptrtest.go
0.519521
0.594257
mergeptrtest.go
starcoder
package automaton import ( "container/list" "fmt" "github.com/balzaczyy/golucene/core/util" "unicode" ) // Basic automata operations. /* Returns an automaton that accepts the concatenation of the languages of the given automata. Complexity: linear in total number of states. */ func concatenate(a1, a2 *Automaton) *Automaton { return concatenateN([]*Automaton{a1, a2}) } /* Returns an automaton that accepts the concatenation of the languages of the given automata. Complexity: linear in total number of states. */ func concatenateN(l []*Automaton) *Automaton { ans := newEmptyAutomaton() // first pass: create all states for _, a := range l { if a.numStates() == 0 { ans.finishState() return ans } numStates := a.numStates() for s := 0; s < numStates; s++ { ans.createState() } } // second pass: add transitions, carefully linking accept // states of A to init state of next A: stateOffset := 0 t := newTransition() for i, a := range l { numStates := a.numStates() var nextA *Automaton if i < len(l)-1 { nextA = l[i+1] } for s := 0; s < numStates; s++ { numTransitions := a.initTransition(s, t) for j := 0; j < numTransitions; j++ { a.nextTransition(t) ans.addTransitionRange(stateOffset+s, stateOffset+t.dest, t.min, t.max) } if a.IsAccept(s) { followA := nextA followOffset := stateOffset upto := i + 1 for { if followA != nil { // adds a "virtual" epsilon transition: numTransitions = followA.initTransition(0, t) for j := 0; j < numTransitions; j++ { followA.nextTransition(t) ans.addTransitionRange(stateOffset+s, followOffset+numStates+t.dest, t.min, t.max) } if followA.IsAccept(0) { // keep chaning if followA accepts empty string followOffset += followA.numStates() if upto < len(l)-1 { followA = l[upto+1] } else { followA = nil } upto++ } else { break } } else { ans.setAccept(stateOffset+s, true) break } } } } stateOffset += numStates } if ans.numStates() == 0 { ans.createState() } ans.finishState() return ans } /* Returns an automaton that accepts the union of the empty string and the language of the given automaton. Complexity: linear in number of states. */ func optional(a *Automaton) *Automaton { ans := newEmptyAutomaton() ans.createState() ans.setAccept(0, true) if a.numStates() > 0 { ans.copy(a) ans.addEpsilon(0, 1) } ans.finishState() return ans } /* Returns an automaton that accepts the Kleene star (zero or more concatenated repetitions) of the language of the given automaton. Never modifies the input automaton language. Complexity: linear in number of states. */ func repeat(a *Automaton) *Automaton { if isEmpty(a) { return a } b := newAutomatonBuilder() b.createState() b.setAccept(0, true) b.copy(a) t := newTransition() count := a.initTransition(0, t) for i := 0; i < count; i++ { a.nextTransition(t) b.addTransitionRange(0, t.dest+1, t.min, t.max) } numStates := a.numStates() for s := 0; s < numStates; s++ { if a.IsAccept(s) { count = a.initTransition(0, t) for i := 0; i < count; i++ { a.nextTransition(t) b.addTransitionRange(s+1, t.dest+1, t.min, t.max) } } } return b.finish() } /* Returns an automaton that accepts min or more concatenated repetitions of the language of the given automaton. Complexity: linear in number of states and in min. */ func repeatMin(a *Automaton, min int) *Automaton { if min == 0 { return repeat(a) } as := make([]*Automaton, 0, min+1) for min > 0 { as = append(as, a) min-- } as = append(as, repeat(a)) return concatenateN(as) } /* Returns a (deterministic) automaton that accepts the complement of the language of the given automaton. Complexity: linear in number of states (if already deterministic). */ func complement(a *Automaton) *Automaton { a = totalize(determinize(a)) numStates := a.numStates() for p := 0; p < numStates; p++ { a.setAccept(p, !a.IsAccept(p)) } return removeDeadStates(a) } /* Returns a (deterministic) automaton that accepts the intersection of the language of a1 and the complement of the language of a2. As a side-effect, the automata may be determinized, if not already deterministic. Complexity: quadratic in number of states (if already deterministic). */ func minus(a1, a2 *Automaton) *Automaton { if isEmpty(a1) || a1 == a2 { return MakeEmpty() } if isEmpty(a2) { return a1 } return intersection(a1, complement(a2)) } // Pair of states. type StatePair struct{ s, s1, s2 int } /* Returns an automaton that accepts the intersection of the languages of the given automata. Never modifies the input automata languages. Complexity: quadratic in number of states. */ func intersection(a1, a2 *Automaton) *Automaton { if a1 == a2 || a1.numStates() == 0 { return a1 } if a2.numStates() == 0 { return a2 } transitions1 := a1.sortedTransitions() transitions2 := a2.sortedTransitions() c := newEmptyAutomaton() c.createState() worklist := list.New() newstates := make(map[string]*StatePair) hash := func(p *StatePair) string { return fmt.Sprintf("%v/%v", p.s1, p.s2) } p := &StatePair{0, 0, 0} worklist.PushBack(p) newstates[hash(p)] = p for worklist.Len() > 0 { p = worklist.Remove(worklist.Front()).(*StatePair) c.setAccept(p.s, a1.IsAccept(p.s1) && a2.IsAccept(p.s2)) t1 := transitions1[p.s1] t2 := transitions2[p.s2] for n1, b2 := 0, 0; n1 < len(t1); n1++ { for b2 < len(t2) && t2[b2].max < t1[n1].min { b2++ } for n2 := b2; n2 < len(t2) && t1[n1].max >= t2[n2].min; n2++ { if t2[n2].max >= t1[n1].min { q := &StatePair{-1, t1[n1].dest, t2[n2].dest} r, ok := newstates[hash(q)] if !ok { q.s = c.createState() worklist.PushBack(q) newstates[hash(q)] = q r = q } min := or(t1[n1].min > t2[n2].min, t1[n1].min, t2[n2].min).(int) max := or(t1[n1].max < t2[n2].max, t1[n1].max, t2[n2].max).(int) c.addTransitionRange(p.s, r.s, min, max) } } } } c.finishState() return removeDeadStates(c) } /* Returns true if these two automata accept exactly the same language. This is a costly computation! Note also that a1 and a2 will be determinized as a side effect. */ func sameLanguage(a1, a2 *Automaton) bool { if a1 == a2 { return true } return subsetOf(a2, a1) && subsetOf(a1, a2) } /* Returns true if the automaton has any states that cannot be reached from the initial state or cannot reach an accept state. Cost is O(numTransitions+numStates). */ func hasDeadStates(a *Automaton) bool { liveStates := liveStates(a) numLive := liveStates.Cardinality() numStates := a.numStates() assert2(numLive <= int64(numStates), "numLive=%v numStates=%v %v", numLive, numStates, liveStates) return numLive < int64(numStates) } func hasDeadStatesFromInitial(a *Automaton) bool { r1 := liveStatesFromInitial(a) r2 := liveStatesToAccept(a) r1.AndNot(r2) return !r1.IsEmpty() } /* Returns true if the language of a1 is a subset of the language of a2. As a side-effect, a2 is determinized if not already marked as deterministic. */ func subsetOf(a1, a2 *Automaton) bool { assert2(a1.deterministic, "a1 must be deterministic") assert2(a2.deterministic, "a2 must be deterministic") assert(!hasDeadStatesFromInitial(a1)) assert2(!hasDeadStatesFromInitial(a2), "%v", a2) if a1.numStates() == 0 { // empty language is always a subset of any other language return true } else if a2.numStates() == 0 { return isEmpty(a1) } transitions1 := a1.sortedTransitions() transitions2 := a2.sortedTransitions() worklist := list.New() visited := make(map[string]*StatePair) hash := func(p *StatePair) string { return fmt.Sprintf("%v/%v", p.s1, p.s2) } p := &StatePair{-1, 0, 0} worklist.PushBack(p) visited[hash(p)] = p for worklist.Len() > 0 { p = worklist.Remove(worklist.Front()).(*StatePair) if a1.IsAccept(p.s1) && !a2.IsAccept(p.s2) { return false } t1 := transitions1[p.s1] t2 := transitions2[p.s2] for n1, b2, t1Len := 0, 0, len(t1); n1 < t1Len; n1++ { t2Len := len(t2) for b2 < t2Len && t2[b2].max < t1[n1].min { b2++ } min1, max1 := t1[n1].min, t1[n1].max for n2 := b2; n2 < t2Len && t1[n1].max >= t2[n2].min; n2++ { if t2[n2].min > min1 { return false } if t2[n2].max < unicode.MaxRune { min1 = t2[n2].max + 1 } else { min1, max1 = unicode.MaxRune, MIN_CODE_POINT } q := &StatePair{-1, t1[n1].dest, t2[n2].dest} if _, ok := visited[hash(q)]; !ok { worklist.PushBack(q) visited[hash(q)] = q } } if min1 <= max1 { return false } } } return true } /* Returns an automaton that accepts the union of the languages of the given automta. Complexity: linear in number of states. */ func union(a1, a2 *Automaton) *Automaton { return unionN([]*Automaton{a1, a2}) } /* Returns an automaton that accepts the union of the languages of the given automata. Complexity: linear in number of states. */ func unionN(l []*Automaton) *Automaton { ans := newEmptyAutomaton() // create initial state ans.createState() // copy over all automata for _, a := range l { ans.copy(a) } // add epsilon transition from new initial state stateOffset := 1 for _, a := range l { if a.numStates() == 0 { continue } ans.addEpsilon(0, stateOffset) stateOffset += a.numStates() } ans.finishState() return removeDeadStates(ans) } /* Simple custom []*Transition */ type TransitionList struct { transitions []int // dest,min,max } func (l *TransitionList) add(t *Transition) { l.transitions = append(l.transitions, t.dest, t.min, t.max) } // Holds all transitions that start on this int point, or end at this // point-1 type PointTransitions struct { point int ends *TransitionList starts *TransitionList } func newPointTransitions() *PointTransitions { return &PointTransitions{ ends: new(TransitionList), starts: new(TransitionList), } } func (pt *PointTransitions) reset(point int) { pt.point = point pt.ends.transitions = pt.ends.transitions[:0] pt.starts.transitions = pt.starts.transitions[:0] } const HASHMAP_CUTOVER = 30 type PointTransitionSet struct { points []*PointTransitions dict map[int]*PointTransitions useHash bool } func newPointTransitionSet() *PointTransitionSet { return &PointTransitionSet{ points: make([]*PointTransitions, 0, 5), dict: make(map[int]*PointTransitions), useHash: false, } } func (pts *PointTransitionSet) next(point int) *PointTransitions { // 1st time we are seeing this point p := newPointTransitions() pts.points = append(pts.points, p) p.reset(point) return p } func (pts *PointTransitionSet) find(point int) *PointTransitions { if pts.useHash { p, ok := pts.dict[point] if !ok { p = pts.next(point) pts.dict[point] = p } return p } for _, p := range pts.points { if p.point == point { return p } } p := pts.next(point) if len(pts.points) == HASHMAP_CUTOVER { // switch to hash map on the fly assert(len(pts.dict) == 0) for _, v := range pts.points { pts.dict[v.point] = v } pts.useHash = true } return p } func (pts *PointTransitionSet) reset() { if pts.useHash { pts.dict = make(map[int]*PointTransitions) pts.useHash = false } pts.points = pts.points[:0] // reuse slice } type PointTransitionsArray []*PointTransitions func (a PointTransitionsArray) Len() int { return len(a) } func (a PointTransitionsArray) Less(i, j int) bool { return a[i].point < a[j].point } func (a PointTransitionsArray) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (pts *PointTransitionSet) sort() { // Tim sort performs well on already sorted arrays: if len(pts.points) > 0 { util.TimSort(PointTransitionsArray(pts.points)) } } func (pts *PointTransitionSet) add(t *Transition) { pts.find(t.min).starts.add(t) pts.find(1 + t.max).ends.add(t) } func (pts *PointTransitionSet) String() string { panic("not implemented yet") } /* Determinizes the given automaton. Split the code points in ranges, and merge overlapping states. Worst case complexity: exponential in number of states. */ func determinize(a *Automaton) *Automaton { if a.deterministic || a.numStates() <= 1 { return a } // subset construction b := newAutomatonBuilder() // fmt.Println("DET:") initialset := newFrozenIntSetOf(0, 0) // craete state 0: b.createState() worklist := list.New() newstate := make(map[string]int) hash := func(s *FrozenIntSet) string { return s.String() } worklist.PushBack(initialset) b.setAccept(0, a.IsAccept(0)) newstate[hash(initialset)] = 0 // like map[int]*PointTransitions points := newPointTransitionSet() // like sorted map[int]int statesSet := newSortedIntSet(5) t := newTransition() for worklist.Len() > 0 { s := worklist.Remove(worklist.Front()).(*FrozenIntSet) // fmt.Printf("det: pop set=%v\n", s) // Collate all outgoing transitions by min/1+max for _, s0 := range s.values { numTransitions := a.numTransitions(s0) a.initTransition(s0, t) for j := 0; j < numTransitions; j++ { a.nextTransition(t) points.add(t) } } if len(points.points) == 0 { // No outgoing transitions -- skip it continue } points.sort() lastPoint := -1 accCount := 0 r := s.state for _, v := range points.points { point := v.point if len(statesSet.values) > 0 { assert(lastPoint != -1) hashKey := statesSet.computeHash().String() q, ok := newstate[hashKey] if !ok { q = b.createState() p := statesSet.freeze(q) // fmt.Printf(" make new state=%v -> %v accCount=%v\n", q, p, accCount) worklist.PushBack(p) b.setAccept(q, accCount > 0) newstate[hash(p)] = q } else { assert2(b.isAccept(q) == (accCount > 0), "accCount=%v vs existing accept=%v states=%v", accCount, b.isAccept(q), statesSet) } // fmt.Printf(" add trans src=%v dest=%v min=%v max=%v\n", // r, q, lastPoint, point-1) b.addTransitionRange(r, q, lastPoint, point-1) } // process transitions that end on this point // (closes an overlapping interval) for j, limit := 0, len(v.ends.transitions); j < limit; j += 3 { dest := v.ends.transitions[j] statesSet.decr(dest) if a.IsAccept(dest) { accCount-- } } v.ends.transitions = v.ends.transitions[:0] // reuse slice // process transitions that start on this point // (opens a new interval) for j, limit := 0, len(v.starts.transitions); j < limit; j += 3 { dest := v.starts.transitions[j] statesSet.incr(dest) if a.IsAccept(dest) { accCount++ } } v.starts.transitions = v.starts.transitions[:0] // reuse slice lastPoint = point } points.reset() assert2(len(statesSet.values) == 0, "upto=%v", len(statesSet.values)) } ans := b.finish() assert(ans.deterministic) return ans } // // L779 // Returns true if the given automaton accepts no strings. func isEmpty(a *Automaton) bool { if a.numStates() == 0 { // common case: no states return true } if !a.IsAccept(0) && a.numTransitions(0) == 0 { // common case: just one initial state return true } if a.IsAccept(0) { // apparently common case: it accepts the empty string return false } workList := list.New() seen := util.NewOpenBitSet() workList.PushBack(0) seen.Set(0) t := newTransition() for workList.Len() > 0 { state := workList.Remove(workList.Front()).(int) if a.IsAccept(state) { return false } count := a.initTransition(state, t) for i := 0; i < count; i++ { a.nextTransition(t) if !seen.Get(int64(t.dest)) { workList.PushBack(t.dest) seen.Set(int64(t.dest)) } } } return true } // /* // Returns true if the given string is accepted by the autmaton. // Complexity: linear in the length of the string. // Note: for fll performance, use the RunAutomation class. // */ // func run(a *Automaton, s string) bool { // if a.isSingleton() { // return s == a.singleton // } // if a.deterministic { // p := a.initial // for _, ch := range s { // q := p.step(int(ch)) // if q == nil { // return false // } // p = q // } // return p.accept // } // // states := a.NumberedStates() // panic("not implemented yet") // } /* Returns the set of live states. A state is "live" if an accept state is reachable from it and if it is reachable from the initial state. */ func liveStates(a *Automaton) *util.OpenBitSet { live := liveStatesFromInitial(a) live.And(liveStatesToAccept(a)) return live } /* Returns BitSet marking states reachable from the initial state. */ func liveStatesFromInitial(a *Automaton) *util.OpenBitSet { numStates := a.numStates() live := util.NewOpenBitSet() if numStates == 0 { return live } workList := list.New() live.Set(0) workList.PushBack(0) t := newTransition() for workList.Len() > 0 { s := workList.Remove(workList.Front()).(int) count := a.initTransition(s, t) for i := 0; i < count; i++ { a.nextTransition(t) if !live.Get(int64(t.dest)) { live.Set(int64(t.dest)) workList.PushBack(t.dest) } } } return live } /* Returns BitSet marking states that can reach an accept state. */ func liveStatesToAccept(a *Automaton) *util.OpenBitSet { builder := newAutomatonBuilder() // NOTE: not quite the same thing as what SpecialOperations.reverse does: t := newTransition() numStates := a.numStates() for s := 0; s < numStates; s++ { builder.createState() } for s := 0; s < numStates; s++ { count := a.initTransition(s, t) for i := 0; i < count; i++ { a.nextTransition(t) builder.addTransitionRange(t.dest, s, t.min, t.max) } } a2 := builder.finish() workList := list.New() live := util.NewOpenBitSet() acceptBits := a.isAccept s := 0 for s < numStates { s = int(acceptBits.NextSetBit(int64(s))) if s == -1 { break } live.Set(int64(s)) workList.PushBack(s) s++ } for workList.Len() > 0 { s = workList.Remove(workList.Front()).(int) count := a2.initTransition(s, t) for i := 0; i < count; i++ { a2.nextTransition(t) if !live.Get(int64(t.dest)) { live.Set(int64(t.dest)) workList.PushBack(t.dest) } } } return live } /* Removes transitions to dead states (a state is "dead" if it is not reachable from the initial state or no accept state is reachable from it.) */ func removeDeadStates(a *Automaton) *Automaton { numStates := a.numStates() liveSet := liveStates(a) m := make([]int, numStates) ans := newEmptyAutomaton() // fmt.Printf("liveSet: %v numStates=%v\n", liveSet, numStates) for i := 0; i < numStates; i++ { if liveSet.Get(int64(i)) { m[i] = ans.createState() ans.setAccept(m[i], a.IsAccept(i)) } } t := newTransition() for i := 0; i < numStates; i++ { if liveSet.Get(int64(i)) { numTransitions := a.initTransition(i, t) // filter out transitions to dead states: for j := 0; j < numTransitions; j++ { a.nextTransition(t) if liveSet.Get(int64(t.dest)) { ans.addTransitionRange(m[i], m[t.dest], t.min, t.max) } } } } ans.finishState() assert(!hasDeadStates(ans)) return ans } /* Finds the largest entry whose value is less than or equal to c, or 0 if there is no such entry. */ func findIndex(c int, points []int) int { a, b := 0, len(points) for b-a > 1 { d := int(uint(a+b) >> 1) if points[d] > c { b = d } else if points[d] < c { a = d } else { return d } } return a } /* Returns an automaton accepting the reverse language. */ func reverse(a *Automaton) (*Automaton, map[int]bool) { if isEmpty(a) { return newEmptyAutomaton(), nil } numStates := a.numStates() // build a new automaton with all edges reversed b := newAutomatonBuilder() // initial node; we'll add epsilon transitions in the end: b.createState() for s := 0; s < numStates; s++ { b.createState() } // old initial state becomes new accept state: b.setAccept(1, true) t := newTransition() for s := 0; s < numStates; s++ { numTransitions := a.numTransitions(s) a.initTransition(s, t) for i := 0; i < numTransitions; i++ { a.nextTransition(t) b.addTransitionRange(t.dest+1, s+1, t.min, t.max) } } ans := b.finish() initialStates := make(map[int]bool) acceptStates := a.isAccept for s := acceptStates.NextSetBit(0); s != -1; s = acceptStates.NextSetBit(s + 1) { ans.addEpsilon(0, int(s+1)) initialStates[int(s+1)] = true } ans.finishState() return ans, initialStates } /* Returns a new automaton accepting the same language with added transitions to a dead state so that from every state and every label there is a transition. */ func totalize(a *Automaton) *Automaton { ans := newEmptyAutomaton() numStates := a.numStates() for i := 0; i < numStates; i++ { ans.createState() ans.setAccept(i, a.IsAccept(i)) } deadState := ans.createState() ans.addTransitionRange(deadState, deadState, MIN_CODE_POINT, unicode.MaxRune) t := newTransition() for i := 0; i < numStates; i++ { maxi := MIN_CODE_POINT count := a.initTransition(i, t) for j := 0; j < count; j++ { a.nextTransition(t) ans.addTransitionRange(i, t.dest, t.min, t.max) if t.min > maxi { ans.addTransitionRange(i, deadState, maxi, t.min-1) } if t.max+1 > maxi { maxi = t.max + 1 } } if maxi <= unicode.MaxRune { ans.addTransitionRange(i, deadState, maxi, unicode.MaxRune) } } ans.finishState() return ans }
vendor/github.com/balzaczyy/golucene/core/util/automaton/operations.go
0.75392
0.421611
operations.go
starcoder
package main import ( "image/color" "math" "github.com/hajimehoshi/ebiten" ) func limita(valor, minimo, maximo float32) float32 { if valor < minimo { return minimo } else if valor > maximo { return maximo } else { return valor } } var ( imagemVazia = ebiten.NewImage(2, 2) bolaNumVertices = 16 bolaRaio = 8 bolaIndices = make([]uint16, 0, bolaNumVertices) bolaVertices = make([]ebiten.Vertex, 0, bolaNumVertices+1) bolaVerticesTransformados = make([]ebiten.Vertex, 0, bolaNumVertices+1) ) func init() { imagemVazia.Fill(color.White) reconstroiBola() } func reconstroiBola() { bolaIndices = bolaIndices[:0] bolaVertices = bolaVertices[:0] bolaVerticesTransformados = bolaVerticesTransformados[:0] for i := 0; i < bolaNumVertices; i++ { proporcao := float64(i) / float64(bolaNumVertices) cr := 0.0 cg := 0.0 cb := 0.0 if proporcao < 1.0/3.0 { cb = 2 - 2*(proporcao*3) cr = 2 * (proporcao * 3) } if 1.0/3.0 <= proporcao && proporcao < 2.0/3.0 { cr = 2 - 2*(proporcao-1.0/3.0)*3 cg = 2 * (proporcao - 1.0/3.0) * 3 } if 2.0/3.0 <= proporcao { cg = 2 - 2*(proporcao-2.0/3.0)*3 cb = 2 * (proporcao - 2.0/3.0) * 3 } bolaIndices = append( bolaIndices, uint16(i), uint16(i+1)%uint16(bolaNumVertices), uint16(bolaNumVertices), ) vertice := ebiten.Vertex{ DstX: float32(math.Cos(2 * math.Pi * proporcao)), DstY: float32(math.Sin(2 * math.Pi * proporcao)), SrcX: 0, SrcY: 0, ColorR: float32(cr), ColorG: float32(cg), ColorB: float32(cb), ColorA: 1, } bolaVertices = append(bolaVertices, vertice) bolaVerticesTransformados = append(bolaVerticesTransformados, vertice) } vertice := ebiten.Vertex{ DstX: 0, DstY: 0, SrcX: 0, SrcY: 0, ColorR: 1, ColorG: 1, ColorB: 1, ColorA: 1, } bolaVertices = append(bolaVertices, vertice) bolaVerticesTransformados = append(bolaVerticesTransformados, vertice) } func desenhaBola(tela *ebiten.Image, x, y, raio float32, numVertices int) { if numVertices != bolaNumVertices { bolaNumVertices = numVertices reconstroiBola() } for i, vertice := range bolaVertices { bolaVerticesTransformados[i].DstX = x + vertice.DstX*raio bolaVerticesTransformados[i].DstY = y + vertice.DstY*raio } tela.DrawTriangles(bolaVerticesTransformados, bolaIndices, imagemVazia, nil) }
blockbreaker/util.go
0.506347
0.452354
util.go
starcoder
package telematics import ( "encoding/binary" "errors" "math" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" ) // sampling data is an efficient binary-packed format // each []byte data field contains a set of samples (4 bytes per sample) // each sample contains 3 values of 10 bits each - last 2 bits unused // the 10-bit values are normalized to a unit-specific signed range type GForce float64 type Radians float64 type Acceleration struct { X, Y, Z GForce } type Attitude struct { Roll, Pitch, Yaw Radians } const ( maxAcceleration = GForce(10) maxAttitude = Radians(math.Pi) // these apply to both acceleration and attitude valueNorm = float64(500) valueBits = 10 valueNormMask = ((1 << valueBits) - 1) // 1023 valueNormSignedMax = ((valueNormMask + 1) / 2) // 512 ) const sampleSize = 4 // 4 bytes in a uint32 type AccelerationData []Acceleration type AttitudeData []Attitude func (a *AccelerationData) UnmarshalBSONValue(t bsontype.Type, raw []byte) error { count, data, err := prepSamplingData(t, raw) if err != nil { return err } out := make(AccelerationData, count) for i := 0; i < count; i++ { x, y, z := readSample(data, i, float64(maxAcceleration)) out[i] = Acceleration{ GForce(x), GForce(y), GForce(z), } } *a = out return nil } func (a *AttitudeData) UnmarshalBSONValue(t bsontype.Type, raw []byte) error { count, data, err := prepSamplingData(t, raw) if err != nil { return err } out := make(AttitudeData, count) for i := 0; i < count; i++ { roll, pitch, yaw := readSample(data, i, float64(maxAttitude)) out[i] = Attitude{ Radians(roll), Radians(pitch), Radians(yaw), } } *a = out return nil } func prepSamplingData(t bsontype.Type, raw []byte) (count int, data []byte, err error) { data, _, err = bsonrw.NewBSONValueReader(t, raw).ReadBinary() if err != nil { return } if len(data)%sampleSize != 0 { err = errors.New("invalid []byte length") return } count = len(data) / sampleSize return } func readSample(data []byte, idx int, max float64) (a, b, c float64) { offset := idx * sampleSize end := offset + sampleSize packed := binary.BigEndian.Uint32(data[offset:end]) return unpackSample(packed, max) } func unpackSample(packed uint32, max float64) (a, b, c float64) { a = denormalizeValue(packed>>(0*valueBits), max) b = denormalizeValue(packed>>(1*valueBits), max) c = denormalizeValue(packed>>(2*valueBits), max) return } func denormalizeValue(input uint32, max float64) float64 { value := int32(input) & valueNormMask if value >= valueNormSignedMax { value -= valueNormSignedMax * 2 } return float64(value) * max / valueNorm }
lib/telematics/types_sampling.go
0.787686
0.543348
types_sampling.go
starcoder
// kvstring package contains functions for representing string key:value pairs as one string and converting // such strings to maps etc. package kvstring import ( "fmt" "github.com/pkg/errors" "strconv" ) const ( KeyValueSeparator = "=" FieldsSeparator = "," ) // RemoveCurlyBraces trims leading and trailing spaces and curly braces. For example input strings // like ` { abc } ` will get as a result `abc` string func RemoveCurlyBraces(str string) (string, error) { idx := 0 cnt := 0 for ; idx < len(str); idx++ { c := str[idx] if c == ' ' { continue } if c == '{' { cnt++ continue } break } tidx := len(str) - 1 for ; tidx > idx && cnt >= 0; tidx-- { c := str[tidx] if c == ' ' { continue } if c == '}' { cnt-- continue } break } if tidx == idx || cnt != 0 { return str, fmt.Errorf("improperly formated tags string %s, expected format must be either {k=v, ...} or k=v,.. ", str) } return str[idx : tidx+1], nil } // SplitString receves key-value string where the key-value separator is kvSep, and the pairs are separated by fldSep. // For example in the string `name=app1,ip=1234` the kvSep is '=' and fldSep is ','. The SplitString expects the result // buf which will be used for preparing result. key or value could contain fldSep or kvSep chars, if the value is put into // quotes. func SplitString(str string, kvSep, fldSep byte, buf []string) ([]string, error) { inStr := false expCC := kvSep stIdx := 0 endIdx := 0 for ; endIdx < len(str); endIdx++ { c := str[endIdx] if c == '"' { inStr = !inStr continue } if c == '\\' && inStr { endIdx++ continue } if (c == kvSep || c == fldSep) && !inStr { if c != expCC { return nil, fmt.Errorf("unexpected separator at %d of %s. Expected %c, but actually %c", endIdx, str, expCC, c) } if expCC == kvSep { expCC = fldSep } else { expCC = kvSep } buf = append(buf, str[stIdx:endIdx]) stIdx = endIdx + 1 continue } } if inStr { return nil, fmt.Errorf("unexpected end of string %s. Quotation %t is not closed", str, inStr) } buf = append(buf, str[stIdx:endIdx]) return buf, nil } // ToMap turns a key-value string into map. For example the string `{ name=app, ccc="ddd" }` will be turned into // a map, which equals to map[string]string{"name":"app", "ccc", "ddd"} func ToMap(kvs string) (map[string]string, error) { fine, err := RemoveCurlyBraces(kvs) if err != nil { return nil, err } if len(fine) == 0 { return map[string]string{}, nil } var buf [40]string res, err := SplitString(fine, KeyValueSeparator[0], FieldsSeparator[0], buf[:0]) if err != nil { return nil, err } if len(res)&1 == 1 { return nil, fmt.Errorf("the tag must be a pair of <key>=<value>") } mp := make(map[string]string, len(res)/2) for i := 0; i < len(res); i += 2 { k := TrimSpaces(res[i]) v := TrimSpaces(res[i+1]) if len(k) == 0 { return nil, errors.Errorf("tag name (for value=%s) could not be empty: %s", kvs, v) } if len(v) > 0 && (v[0] == '"' || v[0] == '`') { v1 := v v, err = strconv.Unquote(v) if err != nil { return nil, errors.Wrapf(err, "wrong value for tag \"%s\" which is %s, seems quotated, but could not unqote it", k, v1) } } mp[k] = v } return mp, nil } // MapsEquals returns whether m1 equals to m2 func MapsEquals(m1, m2 map[string]string) bool { if len(m1) != len(m2) { return false } return MapSubset(m1, m2) } // MapSubset returns whether m1 is subset of m2 (all m1's key-values are in m2 as well) func MapSubset(m1, m2 map[string]string) bool { for k, v := range m1 { if v2, ok := m2[k]; !ok || v2 != v { return false } } return true } // trimSpaces removes leading and tailing spaces func TrimSpaces(str string) string { i := 0 for ; i < len(str); i++ { if str[i] == ' ' { continue } break } j := len(str) - 1 for ; j > i; j-- { if str[j] == ' ' { continue } break } return str[i : j+1] }
pkg/utils/kvstring/kvstring.go
0.661704
0.498718
kvstring.go
starcoder
package utils import ( "crypto/rand" "encoding/binary" "math/big" "github.com/centrifuge/go-centrifuge/errors" "github.com/centrifuge/gocelery" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ) // ContainsBigIntInSlice checks if value is present in list. func ContainsBigIntInSlice(value *big.Int, list []*big.Int) bool { for _, v := range list { if v.Cmp(value) == 0 { return true } } return false } // SliceToByte32 converts a 32 byte slice to an array. Will throw error if the slice is too long func SliceToByte32(in []byte) (out [32]byte, err error) { if len(in) > 32 { return [32]byte{}, errors.New("input exceeds length of 32") } copy(out[:], in) return out, nil } // MustSliceToByte32 converts the bytes to byte 32 // panics if the input length is > 32 bytes. func MustSliceToByte32(in []byte) [32]byte { out, err := SliceToByte32(in) if err != nil { panic(err) } return out } // IsEmptyAddress checks if the addr is empty. func IsEmptyAddress(addr common.Address) bool { return addr.Hex() == "0x0000000000000000000000000000000000000000" } // SliceOfByteSlicesToHexStringSlice converts the given slice of byte slices to a hex encoded string array with 0x prefix func SliceOfByteSlicesToHexStringSlice(byteSlices [][]byte) []string { hexArr := make([]string, len(byteSlices)) for i, b := range byteSlices { hexArr[i] = hexutil.Encode(b) } return hexArr } // Byte32ToSlice converts a [32]bytes to an unbounded byte array func Byte32ToSlice(in [32]byte) []byte { if IsEmptyByte32(in) { return []byte{} } return in[:] } // Check32BytesFilled ensures byte slice is of length 32 and don't contain all 0x0 bytes. func Check32BytesFilled(b []byte) bool { return !IsEmptyByteSlice(b) && (len(b) == 32) } // CheckMultiple32BytesFilled takes multiple []byte slices and ensures they are all of length 32 and don't contain all 0x0 bytes. func CheckMultiple32BytesFilled(b []byte, bs ...[]byte) bool { bs = append(bs, b) for _, v := range bs { if !Check32BytesFilled(v) { return false } } return true } // AddressTo32Bytes converts an address to 32 a byte array // The length of an address is 20 bytes. First 12 bytes are filled with zeros. func AddressTo32Bytes(address common.Address) [32]byte { addressBytes := address.Bytes() address32Byte := [32]byte{} for i := 1; i <= common.AddressLength; i++ { address32Byte[32-i] = addressBytes[common.AddressLength-i] } return address32Byte } // ByteArrayTo32BytesLeftPadded converts an address to 32 a byte array // The length of the input has to be less or equals to 32 func ByteArrayTo32BytesLeftPadded(in []byte) ([32]byte, error) { byte32 := [32]byte{} if len(in) > 32 { return byte32, errors.New("incorrect input length %d should be 32", len(in)) } padLength := 32 - len(in) out := append(make([]byte, padLength), in...) return SliceToByte32(out) } // RandomSlice returns a randomly filled byte array with length of given size func RandomSlice(size int) (out []byte) { r := make([]byte, size) _, err := rand.Read(r) // Note that err == nil only if we read len(b) bytes. if err != nil { panic(err) } return r } // RandomByte32 returns a randomly filled byte array with length of 32 func RandomByte32() (out [32]byte) { r := RandomSlice(32) copy(out[:], r[:32]) return } // IsEmptyByte32 checks if the source is empty. func IsEmptyByte32(source [32]byte) bool { sl := make([]byte, 32) copy(sl, source[:32]) return IsEmptyByteSlice(sl) } // IsEmptyByteSlice checks if the provided slice is empty // returns true if: // s == nil // every element is == 0 func IsEmptyByteSlice(s []byte) bool { if s == nil { return true } for _, v := range s { if v != 0 { return false } } return true } // IsSameByteSlice checks if a and b contains same bytes. func IsSameByteSlice(a []byte, b []byte) bool { if a == nil && b == nil { return true } if a == nil || b == nil { return false } if len(a) != len(b) { return false } for i := range a { if a[i] != b[i] { return false } } return true } // ByteSliceToBigInt convert bute slices to big.Int (bigendian) func ByteSliceToBigInt(slice []byte) *big.Int { bi := new(big.Int) bi.SetBytes(slice) return bi } // ByteFixedToBigInt convert arbitrary length byte arrays to big.Int func ByteFixedToBigInt(bytes []byte, size int) *big.Int { bi := new(big.Int) bi.SetBytes(bytes[:size]) return bi } // SimulateJSONDecodeForGocelery encodes and decodes the kwargs. func SimulateJSONDecodeForGocelery(kwargs map[string]interface{}) (map[string]interface{}, error) { t1 := gocelery.TaskMessage{Kwargs: kwargs} encoded, err := t1.Encode() if err != nil { return nil, err } t2, err := gocelery.DecodeTaskMessage(encoded) return t2.Kwargs, err } // IsValidByteSliceForLength checks if the len(slice) == length. func IsValidByteSliceForLength(slice []byte, length int) bool { return len(slice) == length } // ConvertIntToByte32 converts an integer into a fixed length byte array with BigEndian order func ConvertIntToByte32(n int) ([32]byte, error) { buf := make([]byte, 32) binary.BigEndian.PutUint64(buf, uint64(n)) return SliceToByte32(buf) } // ConvertByte32ToInt converts a fixed length byte array into int with BigEndian order func ConvertByte32ToInt(nb [32]byte) int { return int(binary.BigEndian.Uint64(nb[:])) } // ConvertProofForEthereum converts a proof to 32 byte format needed by ethereum func ConvertProofForEthereum(sortedHashes [][]byte) ([][32]byte, error) { var hashes [][32]byte for _, hash := range sortedHashes { hash32, err := SliceToByte32(hash) if err != nil { return nil, err } hashes = append(hashes, hash32) } return hashes, nil } // RandomBigInt returns a random big int that's less than the provided max. func RandomBigInt(max string) (*big.Int, error) { m := new(big.Int) _, ok := m.SetString(max, 10) if !ok { return nil, errors.New("probably not a number %s", max) } //Generate cryptographically strong pseudo-random between 0 - m n, err := rand.Int(rand.Reader, m) if err != nil { return nil, err } return n, nil } // InRange returns a boolean if the given number is in between a specified range. func InRange(i, min, max int) bool { if (i >= min) && (i <= max) { return true } return false }
utils/tools.go
0.754282
0.510741
tools.go
starcoder
package zklog import ( "crypto/rand" "github.com/Zondax/multi-party-sig/pkg/hash" "github.com/Zondax/multi-party-sig/pkg/math/curve" "github.com/Zondax/multi-party-sig/pkg/math/sample" ) type Public struct { // H = b⋅G H curve.Point // X = a⋅G X curve.Point // Y = a⋅H Y curve.Point } type Private struct { // A = a A curve.Scalar // B = b B curve.Scalar } type Commitment struct { // A = α⋅G A curve.Point // B = α⋅H B curve.Point // C = β⋅G C curve.Point } type Proof struct { group curve.Curve *Commitment // Z1 = α+ea (mod q) Z1 curve.Scalar // Z2 = β+eb (mod q) Z2 curve.Scalar } func (p *Proof) IsValid() bool { if p == nil { return false } if p.A.IsIdentity() || p.B.IsIdentity() || p.C.IsIdentity() { return false } if p.Z1.IsZero() || p.Z2.IsZero() { return false } return true } func NewProof(group curve.Curve, hash *hash.Hash, public Public, private Private) *Proof { alpha := sample.Scalar(rand.Reader, group) beta := sample.Scalar(rand.Reader, group) commitment := &Commitment{ A: alpha.ActOnBase(), // A = α⋅G B: alpha.Act(public.H), // B = α⋅H C: beta.ActOnBase(), // C = β⋅H } e, _ := challenge(hash, group, public, commitment) return &Proof{ group: group, Commitment: commitment, Z1: group.NewScalar().Set(e).Mul(private.A).Add(alpha), // Z₁ = α+ea (mod q) Z2: group.NewScalar().Set(e).Mul(private.B).Add(beta), // Z₂ = β+eb (mod q) } } func (p Proof) Verify(hash *hash.Hash, public Public) bool { if !p.IsValid() { return false } e, err := challenge(hash, p.group, public, p.Commitment) if err != nil { return false } { lhs := p.Z1.ActOnBase() // lhs = z₁⋅G rhs := e.Act(public.X).Add(p.A) // rhs = A+e⋅X if !lhs.Equal(rhs) { return false } } { lhs := p.Z1.Act(public.H) // lhs = z₁⋅H rhs := e.Act(public.Y).Add(p.B) // rhs = B+e⋅Y if !lhs.Equal(rhs) { return false } } { lhs := p.Z2.ActOnBase() // lhs = z₂⋅G rhs := e.Act(public.H).Add(p.C) // rhs = C+e⋅H if !lhs.Equal(rhs) { return false } } return true } func challenge(hash *hash.Hash, group curve.Curve, public Public, commitment *Commitment) (e curve.Scalar, err error) { err = hash.WriteAny(public.H, public.X, public.Y, commitment.A, commitment.B, commitment.C) e = sample.Scalar(hash.Digest(), group) return } func Empty(group curve.Curve) *Proof { return &Proof{ group: group, Commitment: &Commitment{ A: group.NewPoint(), B: group.NewPoint(), C: group.NewPoint(), }, Z1: group.NewScalar(), Z2: group.NewScalar(), } }
pkg/zk/log/log.go
0.77081
0.406126
log.go
starcoder
package mongodb import ( "time" "github.com/eroatta/src-reader/entity" "github.com/google/uuid" ) // analysisMapper maps an AnalysisResults entity between its model and database representation. type analysisMapper struct{} // toDTO maps the entity for AnalysisResults into a Data Transfer Object. func (am *analysisMapper) toDTO(ent entity.AnalysisResults) analysisDTO { return analysisDTO{ ID: ent.ID.String(), CreatedAt: ent.DateCreated, ProjectID: ent.ProjectID.String(), ProjectRef: ent.ProjectName, Miners: ent.PipelineMiners, Splitters: ent.PipelineSplitters, Expanders: ent.PipelineExpanders, Files: summarizerDTO{ Total: int32(ent.FilesTotal), Valid: int32(ent.FilesValid), Failed: int32(ent.FilesError), ErrorSamples: ent.FilesErrorSamples, }, Identifiers: summarizerDTO{ Total: int32(ent.IdentifiersTotal), Valid: int32(ent.IdentifiersValid), Failed: int32(ent.IdentifiersError), ErrorSamples: ent.IdentifiersErrorSamples, }, } } // toEntity maps the Data Transfer Object for AnalysisResults into a domain entity. func (am *analysisMapper) toEntity(dto analysisDTO) entity.AnalysisResults { return entity.AnalysisResults{ ID: uuid.MustParse(dto.ID), DateCreated: dto.CreatedAt, ProjectName: dto.ProjectRef, ProjectID: uuid.MustParse(dto.ProjectID), PipelineMiners: dto.Miners, PipelineSplitters: dto.Splitters, PipelineExpanders: dto.Expanders, FilesTotal: int(dto.Files.Total), FilesValid: int(dto.Files.Valid), FilesError: int(dto.Files.Failed), FilesErrorSamples: dto.Files.ErrorSamples, IdentifiersTotal: int(dto.Identifiers.Total), IdentifiersValid: int(dto.Identifiers.Valid), IdentifiersError: int(dto.Identifiers.Failed), IdentifiersErrorSamples: dto.Identifiers.ErrorSamples, } } // analysisDTO is the database representation for an AnalysisResults. type analysisDTO struct { ID string `bson:"_id"` CreatedAt time.Time `bson:"created_at"` ProjectID string `bson:"project_id"` ProjectRef string `bson:"project_ref"` Miners []string `bson:"miners"` Splitters []string `bson:"splitters"` Expanders []string `bson:"expanders"` Files summarizerDTO `bson:"files_summary"` Identifiers summarizerDTO `bson:"identifiers_summary"` } // summarizerDTO is the database representation for an AnalysisResults summary. type summarizerDTO struct { Total int32 `bson:"total"` Valid int32 `bson:"valid"` Failed int32 `bson:"failed"` ErrorSamples []string `bson:"error_samples"` }
port/outgoing/adapter/repository/mongodb/analysis_mapper.go
0.636692
0.444083
analysis_mapper.go
starcoder
package ark import "fmt" type vector2DProperty struct { X float32 `json:"x"` Y float32 `json:"y"` } func (p *vector2DProperty) Type() PropertyType { return StructVector2DPropertyType } func (p *vector2DProperty) String() string { return fmt.Sprintf("StructVector2DProperty()") } func readVector2DStruct(dataSize int, vr valueReader) (Property, error) { x, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading vector x: %w", err) } y, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading vector y: %w", err) } return &vector2DProperty{x, y}, nil } type vectorProperty struct { X float32 `json:"x"` Y float32 `json:"y"` Z float32 `json:"z"` } func (p *vectorProperty) Type() PropertyType { return StructVectorPropertyType } func (p *vectorProperty) String() string { return fmt.Sprintf("StructVectorProperty()") } func readVectorStruct(dataSize int, vr valueReader) (Property, error) { x, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading vector x: %w", err) } y, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading vector y: %w", err) } z, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading vector z: %w", err) } return &vectorProperty{x, y, z}, nil } type quatProperty struct { X float32 `json:"x"` Y float32 `json:"y"` Z float32 `json:"z"` W float32 `json:"w"` } func (p *quatProperty) Type() PropertyType { return StructQuatPropertyType } func (p *quatProperty) String() string { return fmt.Sprintf("StructQuatProperty()") } func readQuatStruct(dataSize int, vr valueReader) (Property, error) { x, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading quat x: %w", err) } y, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading quat y: %w", err) } z, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading quat z: %w", err) } w, err := vr.readFloat() if err != nil { return nil, fmt.Errorf("Error reading quat w: %w", err) } return &quatProperty{x, y, z, w}, nil } func init() { addStructType("Vector2D", readVector2DStruct) addStructType("Vector", readVectorStruct) addStructType("Rotator", readVectorStruct) addStructType("Quat", readQuatStruct) }
struct_vector.go
0.761627
0.417509
struct_vector.go
starcoder
package poly import ( "github.com/adamcolton/geom/calc/comb" poly1d "github.com/adamcolton/geom/calc/poly" "github.com/adamcolton/geom/d2" ) // Coefficients wraps the concept of a list of d2.V. It must return the length // and be able to return the coefficient at any index. type Coefficients interface { Coefficient(idx int) d2.V Len() int } // X converts and instance of Coefficients into a set of 1D Coefficients using // their X components. type X struct{ Coefficients } // Coefficient returns the X value of the underlying Coefficients. func (x X) Coefficient(idx int) float64 { if idx >= x.Len() || idx < 0 { return 0 } return x.Coefficients.Coefficient(idx).X } // Len returns the Len of the underlying Coefficients. func (x X) Len() int { return x.Coefficients.Len() } // Y converts and instance of Coefficients into a set of 1D Coefficients using // their Y components. type Y struct{ Coefficients } // Coefficient returns the Y value of the underlying Coefficients. func (y Y) Coefficient(idx int) float64 { if idx >= y.Len() || idx < 0 { return 0 } return y.Coefficients.Coefficient(idx).Y } // Len returns the Len of the underlying Coefficients. func (y Y) Len() int { return y.Coefficients.Len() } // Slice fulfills Coefficients using a Slice. type Slice []d2.V // Buf returns and instance of Slice. It will use the provided buffer if // possible. func Buf(ln int, buf []d2.V) Slice { if cap(buf) >= ln { buf = buf[:ln] for i := range buf { buf[i].X, buf[i].Y = 0, 0 } return buf } return make(Slice, ln) } // Coefficient returns the d2.V at the given index if it is in range, otherwise // it returns d2.V{0,0}. func (s Slice) Coefficient(idx int) d2.V { if idx >= s.Len() || idx < 0 { return d2.V{} } return s[idx] } // Len returns the length of the underlying slice. func (s Slice) Len() int { return len(s) } // Sum fulfills Coefficients by adding the two underlying Coefficients together. type Sum [2]Coefficients // Coefficient returns the sum of both Coefficients at the given index. func (s Sum) Coefficient(idx int) d2.V { return s[0].Coefficient(idx).Add(s[1].Coefficient(idx)) } // Len returns the longer of the two underlying Coefficients. func (s Sum) Len() int { ln0 := s[0].Len() if ln1 := s[1].Len(); ln1 > ln0 { return ln1 } return ln0 } // Produce of two Coefficients. type Product [2]Coefficients // Coefficient of the product at the given index. func (p Product) Coefficient(idx int) d2.V { return d2.V{ X: poly1d.Product{X{p[0]}, X{p[1]}}.Coefficient(idx), Y: poly1d.Product{Y{p[0]}, Y{p[1]}}.Coefficient(idx), } } // Len of the product of the Coefficients. func (p Product) Len() int { return p[0].Len() + p[1].Len() - 1 } // Derivative of the underlying Coefficients. type Derivative struct { Coefficients } // Coefficient at idx is (idx+1)*Coefficient(idx+1). func (d Derivative) Coefficient(idx int) d2.V { idx++ return d.Coefficients.Coefficient(idx).Multiply(float64(idx)) } // Len is one less than the underlying Coefficients. func (d Derivative) Len() int { return d.Coefficients.Len() - 1 } // Bezier fulfills Coefficients representing a Bezier as a polynomial. type Bezier []d2.Pt // NewBezier creates a Polynomial from the points used to define a Bezier curve. func NewBezier(pts []d2.Pt) Poly { return Poly{Bezier(pts)} } // Len of the underlying slice func (b Bezier) Len() int { return len(b) } var signTab = [2]float64{1, -1} // Coefficient at the given index of the polynomial representation of the Bezier // curve. func (b Bezier) Coefficient(idx int) d2.V { // B(t) = ∑ binomialCo(l,i) * (1-t)^(l-i) * t^(i) * points[i] l := len(b) - 1 var sum d2.V for i, pt := range b { term := idx - i if term < 0 { break } v := pt.V().Multiply(float64(comb.Binomial(l, i))) s := signTab[term&1] * float64(comb.Binomial(l-i, term)) sum = sum.Add(v.Multiply(s)) } return sum }
d2/curve/poly/coefficients.go
0.858199
0.733571
coefficients.go
starcoder
package transform import ( "image" "image/draw" "math" "github.com/urandom/drawgl" "github.com/urandom/drawgl/interpolator" "github.com/urandom/drawgl/operation/transform/matrix" ) type transformOperation struct { matrix matrix.Matrix3 interpolator string dstB image.Rectangle } func affine(op transformOperation, src *drawgl.FloatImage, mask drawgl.Mask, channel drawgl.Channel, forceLinear bool) (dst *drawgl.FloatImage) { if op.matrix.IsIdentity() { dst = drawgl.CopyImage(src) return } srcB := src.Bounds() dstB := op.dstB if dstB.Empty() { dstB = srcB } adr := srcB.Intersect(affineTransformRect(op.matrix, srcB)) dst = drawgl.NewFloatImage(dstB) if adr.Empty() || srcB.Empty() { return } inverse := op.matrix inverse.Invert() bias := affineTransformRect(inverse, adr).Min bias.X-- bias.Y-- inverse[0][2] -= float64(bias.X) inverse[1][2] -= float64(bias.Y) interpolator := interpolator.New(op.interpolator, src, inverse, bias) it := drawgl.DefaultRectangleIterator(adr, forceLinear) it.Iterate(mask, func(pt image.Point, f float32) { if f == 0 { return } dx := float64(dstB.Min.X+pt.X) + 0.5 dy := float64(dstB.Min.Y+pt.Y) + 0.5 sx := inverse[0][0]*dx + inverse[0][1]*dy + inverse[0][2] sy := inverse[1][0]*dx + inverse[1][1]*dy + inverse[1][2] if !(image.Point{int(sx) + bias.X, int(sy) + bias.Y}).In(srcB) { return } sx += float64(bias.X) sy += float64(bias.Y) orig := src.FloatAt(pt.X, pt.Y) srcC := interpolator.Get(src, sx, sy) dst.UnsafeSetColor(pt.X, pt.Y, drawgl.MaskColor(orig, srcC, channel, f, draw.Over)) }) return } func affineTransformRect(m matrix.Matrix3, sr image.Rectangle) (dr image.Rectangle) { ps := [...]image.Point{ {sr.Min.X, sr.Min.Y}, {sr.Max.X, sr.Min.Y}, {sr.Min.X, sr.Max.Y}, {sr.Max.X, sr.Max.Y}, } for i, p := range ps { sxf := float64(p.X) syf := float64(p.Y) dx := int(math.Floor(m[0][0]*sxf + m[0][1]*syf + m[0][2])) dy := int(math.Floor(m[1][0]*sxf + m[1][1]*syf + m[1][2])) // The +1 adjustments below are because an image.Rectangle is inclusive // on the low end but exclusive on the high end. if i == 0 { dr = image.Rectangle{ Min: image.Point{dx + 0, dy + 0}, Max: image.Point{dx + 1, dy + 1}, } continue } if dr.Min.X > dx { dr.Min.X = dx } dx++ if dr.Max.X < dx { dr.Max.X = dx } if dr.Min.Y > dy { dr.Min.Y = dy } dy++ if dr.Max.Y < dy { dr.Max.Y = dy } } return }
operation/transform/matrix.go
0.72331
0.528777
matrix.go
starcoder
package go_pwentropy import ( "math" "strings" ) // Given a provided password, it will return the number of entropy bits. It is calculated estimating the symbols classes // used in the password, i.e. if there are only lower case characters, if there are lower and upper cases, if it contains // numbers, etc. func EntropyByClasses(pw string) float64 { clsUppers := false clsLowers := false clsNumbers := false clsOthers := false for _, ch := range pw { if ch >= 'A' && ch <= 'Z' { clsUppers = true } else if ch >= 'a' && ch <= 'z' { clsLowers = true } else if ch >= '0' && ch <= '9' { clsNumbers = true } else { clsOthers = true } } symbols := 0 if clsUppers { symbols += 26 } if clsLowers { symbols += 26 } if clsNumbers { symbols += 10 } if clsOthers { symbols += 40 } return entropy(symbols, len(pw)) } // Calculate how many unique symbols in a string func UniqueSymbols(str string) int { uniques := map[rune]bool{} for _, ch := range str { uniques[ch] = true } return len(uniques) } // Calculates the entropy of a password by counting the unique symbols in the password and its length, this is // conservative lower bound to the entropy. (as far as the password is not trivially generated, i.e. based on a dictionary.) func EntropyByUniqueSymbols(pw string) float64 { return entropy(UniqueSymbols(pw), len(pw)) } // Calculates the entropy like UniqueSymbols but removing common words from the length func EntropyByUniqueExclCommonSeqs(pw string) float64 { return entropy(UniqueSymbols(pw), len(pw)-HowManyCommonCharSeqs(pw)) } // Calculates a "fair" entropy, using the average between EntropyByClasses and EntropyByUniqueSymbols func FairEntropy(pw string) float64 { return EntropyByUniqueSymbols(pw)*0.5 + EntropyByClasses(pw)*0.25 + EntropyByUniqueExclCommonSeqs(pw)*0.25 } // Returns how many characters in the password are common char sequences func HowManyCommonCharSeqs(pw string) (r int) { r = 0 loPw := strings.ToLower(pw) for _, w := range COMMON_CHARSEQS { for i := strings.Index(loPw, w); i >= 0; i = strings.Index(loPw, w) { loPw = loPw[:i] + loPw[i+len(w):] r += len(w) } } return r } func entropy(uniqueSymbols int, length int) float64 { if uniqueSymbols == 0 || length == 0 { return 0 } return math.Log2(math.Pow(float64(uniqueSymbols), float64(length))) }
entropy.go
0.68342
0.407392
entropy.go
starcoder
package main import ( "context" "fmt" "sync" "time" ) /* Getting the fastest result from multiple sources In some cases, for example, while integrating information retrieval from multiple sources, you only need the first result, the fastest one, and the other results are irrelevant after that. An example from the real world could be extracting the currency rate to count the price. You have multiple third-party services and because you need to show the prices as fast as possible, you need only the first rate received from any service. This recipe will show the pattern for how to achieve such behavior. The preceding code proposes the solution on executing multiple tasks that output some results, and we need only the first fastest one. The solution uses the Context with the cancel function to call cancel once the first result is obtained. The SearchSrc structure provides the Search method that results in a channel where the result is written. Note that the Search method simulates the delay with the time.Sleep function. The merge function, for each channel from the Search method, triggers the goroutine that writes to the final output channel that is read in the main method. While the first result is received from the output channel produced from the merge function, the CancelFunc stored in the variable cancel is called to cancel the rest of the processing. */ type SearchSrc struct { ID string Delay int } func (s *SearchSrc) Search(ctx context.Context) <-chan string { out := make(chan string) go func() { time.Sleep(time.Duration(s.Delay) * time.Second) select { case out <- "Result " + s.ID: case <-ctx.Done(): fmt.Println("Search received Done()") } close(out) fmt.Println("Search finished for ID: " + s.ID) }() return out } func main() { ctx, cancel := context.WithCancel(context.Background()) src1 := &SearchSrc{"1", 2} src2 := &SearchSrc{"2", 6} r1 := src1.Search(ctx) r2 := src2.Search(ctx) out := merge(ctx, r1, r2) for firstResult := range out { cancel() fmt.Println("First result is: " + firstResult) } } func merge(ctx context.Context, results ...<-chan string) <-chan string { wg := sync.WaitGroup{} out := make(chan string) output := func(c <-chan string) { defer wg.Done() select { case <-ctx.Done(): fmt.Println("Received ctx.Done()") case res := <-c: out <- res } } wg.Add(len(results)) for _, c := range results { go output(c) } go func() { wg.Wait() close(out) }() return out }
concurrency/first.go
0.61555
0.642461
first.go
starcoder
package board type Size struct { XSize uint8 `json:"x_size"` YSize uint8 `json:"y_size"` ZSize uint8 `json:"z_size"` } func uint8ArrayToSize(array [3]uint8) Size { return Size{array[0], array[1], array[2]} } func (s Size) getFlattenSize() int { return int(s.XSize) * int(s.YSize) * int(s.ZSize) } func (s Size) ToUint8() (uint8, uint8, uint8) { return s.XSize, s.YSize, s.ZSize } func (s Size) ToInt() (int, int, int) { return int(s.XSize), int(s.YSize), int(s.ZSize) } type Vector3 struct { X uint8 `json:"x"` // Left is -; Right is + Y uint8 `json:"y"` // Up is -; Down is + Z uint8 `json:"z"` // Above Below; if Z == 0 mean the bottom layer } func (vector Vector3) ToUint8() (uint8, uint8, uint8) { return vector.X, vector.Y, vector.Z } func (vector Vector3) ToInt() (int, int, int) { return int(vector.X), int(vector.Y), int(vector.Z) } func (vector Vector3) getHasTileCheckPosition() []Vector3 { x, y, z := vector.ToUint8() return []Vector3{ vector, {x - 1, y, z}, {x, y - 1, z}, {x - 1, y - 1, z}, } } func (vector Vector3) getTouchPositionLeft() []Vector3 { x, y, z := vector.ToUint8() return []Vector3{ {x - 2, y, z}, {x - 2, y - 1, z}, {x - 2, y + 1, z}, } } func (vector Vector3) getTouchPositionRight() []Vector3 { x, y, z := vector.ToUint8() return []Vector3{ {x + 2, y, z}, {x + 2, y - 1, z}, {x + 2, y + 1, z}, } } func (vector Vector3) getTouchPositionAbove() []Vector3 { x, y, z := vector.ToUint8() return []Vector3{ {x - 1, y - 1, z + 1}, {x, y - 1, z + 1}, {x + 1, y - 1, z + 1}, {x - 1, y, z + 1}, {x, y, z + 1}, {x + 1, y, z + 1}, {x - 1, y + 1, z + 1}, {x, y + 1, z + 1}, {x + 1, y + 1, z + 1}, } } func (vector Vector3) getTouchPositionBelow() []Vector3 { x, y, z := vector.ToUint8() return []Vector3{ {x - 1, y - 1, z - 1}, {x, y - 1, z - 1}, {x + 1, y - 1, z - 1}, {x - 1, y, z - 1}, {x, y, z - 1}, {x + 1, y, z - 1}, {x - 1, y + 1, z - 1}, {x, y + 1, z - 1}, {x + 1, y + 1, z - 1}, } }
internal/board/position.go
0.805058
0.525491
position.go
starcoder
package nn import ( "math" ) // Tensor is an algebraic object that describes a relationship between sets of algebraic objects related to a vector space. type Tensor struct { shape Shape rawData []float64 } // NewTensor creates an instance of tensor. func NewTensor(shape Shape) *Tensor { return &Tensor{ shape: shape.Clone(), rawData: make([]float64, shape.Elements()), } } // TensorFromSlice creates an instance of tensor initialized with a given data. func TensorFromSlice(shape Shape, p []float64) *Tensor { if shape.Elements() != len(p) { panic("invalid length") } tensor := NewTensor(shape) copy(tensor.rawData, p) return tensor } // ReShape reshapes a tensor. func (t *Tensor) ReShape(shape Shape) *Tensor { if t.shape.Elements() != shape.Elements() { panic("invalid shape") } res := t.Clone() res.shape = shape return res } // Clone clones a tensor. func (t *Tensor) Clone() *Tensor { clone := NewTensor(t.shape.Clone()) copy(clone.rawData, t.rawData) return clone } // Shape is shape of a tensor. func (t *Tensor) Shape() Shape { return t.shape.Clone() } // Rank is rank of a tensor. func (t *Tensor) Rank() int { return t.shape.Rank() } // Get gets a value. func (t *Tensor) Get(at Shape) float64 { return t.rawData[t.shape.RawIndex(at)] } // Set sets a value. func (t *Tensor) Set(a float64, at Shape) { t.rawData[t.shape.RawIndex(at)] = a } // BroadCast creates a tensor of the return value that inputs all the elements into the passed function. func (t *Tensor) BroadCast(f func(float64) float64) *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = f(d) } return res } // AddBroadCast adds a value to all elements. func (t *Tensor) AddBroadCast(a float64) *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = d + a } return res } // SubBroadCast subtracts a value​from all elements. func (t *Tensor) SubBroadCast(a float64) *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = d - a } return res } // MulBroadCast multiplies all elements by a value. func (t *Tensor) MulBroadCast(a float64) *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = d * a } return res } // DivBroadCast divides all elements by a value. func (t *Tensor) DivBroadCast(a float64) *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = d / a } return res } // AddTensor adds a tensor. func (t *Tensor) AddTensor(tensor *Tensor) *Tensor { if !t.shape.Equal(tensor.shape) { panic("invalid shape") } res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i := 0; i < len(t.rawData); i++ { res.rawData[i] = t.rawData[i] + tensor.rawData[i] } return res } // SubTensor subtracts a tensor. func (t *Tensor) SubTensor(tensor *Tensor) *Tensor { if !t.shape.Equal(tensor.shape) { panic("invalid shape") } res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i := 0; i < len(t.rawData); i++ { res.rawData[i] = t.rawData[i] - tensor.rawData[i] } return res } // MulTensor multiplies by a tensor. func (t *Tensor) MulTensor(tensor *Tensor) *Tensor { if !t.shape.Equal(tensor.shape) { panic("invalid shape") } res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i := 0; i < len(t.rawData); i++ { res.rawData[i] = t.rawData[i] * tensor.rawData[i] } return res } // DivTensor divides by a tensor. func (t *Tensor) DivTensor(tensor *Tensor) *Tensor { if !t.shape.Equal(tensor.shape) { panic("invalid shape") } res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i := 0; i < len(t.rawData); i++ { res.rawData[i] = t.rawData[i] / tensor.rawData[i] } return res } // Dot is a dot product of tensor. func (t *Tensor) Dot(tensor *Tensor) *Tensor { t1, t2 := t, tensor if t1.Rank() != 2 || t2.Rank() != 2 || t1.shape[1] != t2.shape[0] { panic("invalid rank") } res := NewTensor(Shape{t1.shape[0], t2.shape[1]}) for i := 0; i < t1.shape[0]; i++ { for j := 0; j < t2.shape[1]; j++ { for k := 0; k < t2.shape[0]; k++ { val := res.Get(Shape{i, j}) + t1.Get(Shape{i, k})*t2.Get(Shape{k, j}) res.Set(val, Shape{i, j}) } } } return res } // Sum is sum of all elements. func (t *Tensor) Sum() float64 { var res float64 for _, d := range t.rawData { res += d } return res } // Exp is exp of a tensor. func (t *Tensor) Exp() *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = math.Exp(d) } return res } // Log is log of a tensor. func (t *Tensor) Log() *Tensor { res := &Tensor{ shape: t.Shape(), rawData: make([]float64, len(t.rawData)), } for i, d := range t.rawData { res.rawData[i] = math.Log(d) } return res } // Transpose transpose tensor. func (t *Tensor) Transpose() *Tensor { if t.Rank() != 2 { panic("invalid rank") } res := NewTensor(Shape{t.shape[1], t.shape[0]}) for i := 0; i < t.shape[0]; i++ { for j := 0; j < t.shape[1]; j++ { res.Set(t.Get(Shape{i, j}), Shape{j, i}) } } return res } // Max is maximum value of a tensor. func (t *Tensor) Max() float64 { max := t.rawData[0] for _, x := range t.rawData { if x > max { max = x } } return max } // MaxIndex is a index of a maximum value. func (t *Tensor) MaxIndex() int { index := 0 max := -1.0 for i := 0; i < t.shape.Elements(); i++ { if max < t.rawData[i] { max = t.rawData[i] index = i } } return index }
nn/tensor.go
0.896305
0.78838
tensor.go
starcoder
package ringct import "C" import ( . "github.com/lianxiangcloud/linkchain/libs/cryptonote/types" "github.com/lianxiangcloud/linkchain/libs/cryptonote/xcrypto" ) var Z = Key{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} var I = Key{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} var L = Key{0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10} var G = Key{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66} var EIGHT = Key{0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} var INV_EIGHT = Key{0x79, 0x2f, 0xdc, 0xe2, 0x29, 0xe5, 0x06, 0x61, 0xd0, 0xda, 0x1c, 0x7d, 0xb3, 0x9d, 0xd3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06} var H = Key{0x8b, 0x65, 0x59, 0x70, 0x15, 0x37, 0x99, 0xaf, 0x2a, 0xea, 0xdc, 0x9f, 0xf1, 0xad, 0xd0, 0xea, 0x6c, 0x72, 0x51, 0xd5, 0x41, 0x54, 0xcf, 0xa9, 0x2c, 0x17, 0x3a, 0x0d, 0xd3, 0x9c, 0x1f, 0x94} func Identity() Key { return I } func CurveOrder() Key { return L } func Zero() Key { return Z } //does a * G where a is a scalar and G is the curve basepoint func ScalarmultBase(a Key) Key { return xcrypto.ScalarmultBase(a) } //does a * P where a is a scalar and P is an arbitrary point func ScalarmultKey(p, a Key) (Key, error) { return xcrypto.ScalarmultKey(p, a) } //generates a random secret and corresponding public key func SkpkGen() (sk Key, pk Key) { return xcrypto.SkpkGen() } //Computes aH where H= toPoint(cn_fast_hash(G)), G the basepoint func ScalarmultH(key Key) Key { return xcrypto.ScalarmultH(key) } func ZeroCommit(amount Lk_amount) (Key, error) { return xcrypto.ZeroCommit(amount) } func EcdhEncode(masked *EcdhTuple, sharedSec Key, shortAmount bool) bool { return xcrypto.EcdhEncode(masked, sharedSec, shortAmount) } //Computes 8P func Scalarmult8(p Key) (ret Key, _ error) { return xcrypto.Scalarmult8(p) } func ScAdd(a, b EcScalar) (ret Key) { return xcrypto.ScAdd(a, b) } func ScSub(a, b EcScalar) (ret Key) { return xcrypto.ScSub(a, b) } func SkGen() (ret Key) { return xcrypto.SkGen() } func GenC(a Key, amount Lk_amount) (ret Key, _ error) { return xcrypto.GenC(a, amount) } func AddKeys(a, b Key) (Key, error) { return xcrypto.AddKeys(a, b) } func AddKeyV(a KeyV) (Key, error) { return xcrypto.TlvAddKeyV(a) } func AddKeys2(a, b, B Key) (Key, error) { return xcrypto.AddKeys2(a, b, B) }
libs/cryptonote/ringct/rctops.go
0.556641
0.626567
rctops.go
starcoder
package cimg import ( "errors" "fmt" "image" ) // Image is the concrete image type that is used by all functions inside cimg type Image struct { Pixels []byte Width int Height int Stride int Format PixelFormat Premultiplied bool } // NChan returns the number of channels of the pixel format func NChan(pf PixelFormat) int { switch pf { case PixelFormatRGB: return 3 case PixelFormatBGR: return 3 case PixelFormatRGBX: return 4 case PixelFormatBGRX: return 4 case PixelFormatXBGR: return 4 case PixelFormatXRGB: return 4 case PixelFormatGRAY: return 1 case PixelFormatRGBA: return 4 case PixelFormatBGRA: return 4 case PixelFormatABGR: return 4 case PixelFormatARGB: return 4 case PixelFormatCMYK: return 4 } panic(fmt.Errorf("Unrecognized pixel format %v", pf)) } // NewImage creates a new 8-bit image func NewImage(width, height int, format PixelFormat) *Image { return &Image{ Width: width, Height: height, Stride: width * NChan(format), Format: format, Pixels: make([]byte, height*width*NChan(format)), Premultiplied: false, } } // Wrap an array of bytes into an Image object (do not copy pixels) func WrapImage(width, height int, format PixelFormat, pixels []byte) *Image { return &Image{ Width: width, Height: height, Stride: width * NChan(format), Format: format, Pixels: pixels, Premultiplied: false, } } // Wrap an array of bytes into an Image object, with controllable stride (do not copy pixels) func WrapImageStrided(width, height int, format PixelFormat, pixels []byte, stride int) *Image { return &Image{ Width: width, Height: height, Stride: stride, Format: format, Pixels: pixels, Premultiplied: false, } } // Convert a Go image.Image into a turbo.Image // If allowDeepClone is true, and the source image is type GRAY, NRGBA, or RGBA, // then the resulting Image points directly to the pixel buffer of the source image. func FromImage(src image.Image, allowDeepClone bool) (*Image, error) { dst := &Image{ Width: src.Bounds().Dx(), Height: src.Bounds().Dy(), } switch v := src.(type) { case *image.Gray: dst.Format = PixelFormatGRAY dst.Stride = NChan(dst.Format) * dst.Width if allowDeepClone { dst.Pixels = v.Pix } else { dst.Pixels = make([]byte, dst.Stride*dst.Height) copy(dst.Pixels, v.Pix) } return dst, nil case *image.RGBA: dst.Format = PixelFormatRGBA dst.Premultiplied = true dst.Stride = NChan(dst.Format) * dst.Width if allowDeepClone { dst.Pixels = v.Pix } else { dst.Pixels = make([]byte, dst.Stride*dst.Height) copy(dst.Pixels, v.Pix) } return dst, nil case *image.NRGBA: dst.Format = PixelFormatRGBA dst.Premultiplied = false dst.Stride = NChan(dst.Format) * dst.Width if allowDeepClone { dst.Pixels = v.Pix } else { dst.Pixels = make([]byte, dst.Stride*dst.Height) copy(dst.Pixels, v.Pix) } return dst, nil } return nil, errors.New("Unsupported source image type") } // ToImage returns an image from the Go standard library 'image' package func (img *Image) ToImage() (image.Image, error) { if img.Format == PixelFormatGRAY { dst := image.NewGray(image.Rect(0, 0, img.Width, img.Height)) srcBuf := img.Pixels dstBuf := dst.Pix for y := 0; y < img.Height; y++ { srcP := img.Stride * y dstP := dst.Stride * y copy(dstBuf[dstP:dstP+dst.Stride], srcBuf[srcP:srcP+img.Stride]) } return dst, nil } else if img.Format == PixelFormatRGB || img.Format == PixelFormatBGR { dst := image.NewRGBA(image.Rect(0, 0, img.Width, img.Height)) srcBuf := img.Pixels dstBuf := dst.Pix width := img.Width for y := 0; y < img.Height; y++ { srcP := img.Stride * y dstP := dst.Stride * y if img.Format == PixelFormatBGR { // BGR -> RGB for x := 0; x < width; x++ { dstBuf[dstP] = srcBuf[srcP+2] dstBuf[dstP+1] = srcBuf[srcP+1] dstBuf[dstP+2] = srcBuf[srcP] dstBuf[dstP+3] = 255 srcP += 3 dstP += 4 } } else { for x := 0; x < width; x++ { dstBuf[dstP] = srcBuf[srcP] dstBuf[dstP+1] = srcBuf[srcP+1] dstBuf[dstP+2] = srcBuf[srcP+2] dstBuf[dstP+3] = 255 srcP += 3 dstP += 4 } } } return dst, nil } else if img.Format == PixelFormatRGBA { var dst image.Image var dstStride int var dstBuf []uint8 if img.Premultiplied { d := image.NewRGBA(image.Rect(0, 0, img.Width, img.Height)) dstStride = d.Stride dstBuf = d.Pix dst = d } else { d := image.NewNRGBA(image.Rect(0, 0, img.Width, img.Height)) dstStride = d.Stride dstBuf = d.Pix dst = d } srcBuf := img.Pixels for y := 0; y < img.Height; y++ { srcP := img.Stride * y dstP := dstStride * y copy(dstBuf[dstP:dstP+dstStride], srcBuf[srcP:srcP+img.Stride]) } return dst, nil } else if img.Format == PixelFormatBGRA || img.Format == PixelFormatABGR || img.Format == PixelFormatARGB { var dst image.Image var dstStride int var dstBuf []uint8 if img.Premultiplied { d := image.NewRGBA(image.Rect(0, 0, img.Width, img.Height)) dstStride = d.Stride dstBuf = d.Pix dst = d } else { d := image.NewNRGBA(image.Rect(0, 0, img.Width, img.Height)) dstStride = d.Stride dstBuf = d.Pix dst = d } srcBuf := img.Pixels width := img.Width for y := 0; y < img.Height; y++ { srcP := img.Stride * y dstP := dstStride * y switch img.Format { case PixelFormatBGRA: for x := 0; x < width; x++ { dstBuf[dstP] = srcBuf[srcP+2] dstBuf[dstP+1] = srcBuf[srcP+1] dstBuf[dstP+2] = srcBuf[srcP] dstBuf[dstP+3] = srcBuf[srcP+3] srcP += 4 dstP += 4 } case PixelFormatABGR: for x := 0; x < width; x++ { dstBuf[dstP] = srcBuf[srcP+3] dstBuf[dstP+1] = srcBuf[srcP+2] dstBuf[dstP+2] = srcBuf[srcP+1] dstBuf[dstP+3] = srcBuf[srcP] srcP += 4 dstP += 4 } case PixelFormatARGB: for x := 0; x < width; x++ { dstBuf[dstP] = srcBuf[srcP+1] dstBuf[dstP+1] = srcBuf[srcP+2] dstBuf[dstP+2] = srcBuf[srcP+3] dstBuf[dstP+3] = srcBuf[srcP] srcP += 4 dstP += 4 } } } return dst, nil } else { return nil, fmt.Errorf("Unsupported image type %v", img.Format) } } // Clone returns a deep clone of the image func (img *Image) Clone() *Image { copy := NewImage(img.Width, img.Height, img.Format) copy.Premultiplied = img.Premultiplied copy.CopyImage(img, 0, 0) return copy } // NChan returns the number of channels of the pixel format of the image func (img *Image) NChan() int { return NChan(img.Format) }
v2/image.go
0.713432
0.566019
image.go
starcoder
package wav import ( "fmt" "math" ) // ConvertTo44100Hz2Channels16BitSamples returns the input parameter if the // format is already correct (no copying is done in this case). Otherwise a new // Wave structure is returned and its data is converted to the specified format. // In any case the original data is not changed. func ConvertTo44100Hz2Channels16BitSamples(w *Wave) *Wave { if w.SamplesPerSecond == 44100 && w.ChannelCount == 2 && w.BitsPerSample == 16 { return w } if len(w.Data) == 0 { return w } converted := &Wave{ SamplesPerSecond: 44100, ChannelCount: 2, BitsPerSample: 16, } converted.Data = w.Data if w.BitsPerSample == 8 { converted.Data = convert8bitTo16bitSamples(converted.Data) } if w.ChannelCount == 1 { converted.Data = convert16bitMonoTo16bitStereo(converted.Data) } if w.SamplesPerSecond != 44100 { converted.Data = convert16bitStereoFrequencies( converted.Data, w.SamplesPerSecond, 44100) } return converted } func ConvertToFormat(w *Wave, samplesPerSecond, channels, bitsPerSample int) (*Wave, error) { if w.SamplesPerSecond == samplesPerSecond && w.ChannelCount == channels && w.BitsPerSample == bitsPerSample { return w, nil } if !(bitsPerSample == 8 || bitsPerSample == 16) { return nil, fmt.Errorf( "illegal bit/sample value: %v, must be 8 or 16.", bitsPerSample) } if samplesPerSecond < 1 { return nil, fmt.Errorf( "illegal samples/sec value: %v, must be positive.", samplesPerSecond) } if !(channels == 1 || channels == 2) { return nil, fmt.Errorf( "illegal channel count: %v, must be 1 or 2.", channels) } data := w.Data if w.BitsPerSample == 8 { data = convert8bitTo16bitSamples(data) } if w.ChannelCount == 1 { data = convert16bitMonoTo16bitStereo(data) } if samplesPerSecond != w.SamplesPerSecond { data = convert16bitStereoFrequencies(data, w.SamplesPerSecond, samplesPerSecond) } // now the format has the correct samplesPerSecond value, 16 bits/sample, // 2 channels if channels == 1 { data = convert16bitStereoTo16bitMono(data) } if bitsPerSample == 8 { data = convert16bitTo8bitSamples(data) } converted := &Wave{ SamplesPerSecond: samplesPerSecond, ChannelCount: channels, BitsPerSample: bitsPerSample, Data: data, } return converted, nil } func convert8bitTo16bitSamples(input []byte) []byte { output := make([]byte, len(input)*2) for i, val := range input { const step = 65535 / 255 val16 := int16(int(val)*step - 32768) output[i*2], output[i*2+1] = byte(val16&0xFF), byte((val16>>8)&0xFF) } return output } func convert16bitTo8bitSamples(data []byte) []byte { values := int16Stream(data) data = data[:len(data)/2] for i := range data { const step = 65535 / 255 data[i] = byte((int(values()) + 32768) / step) } return data } func convert16bitMonoTo16bitStereo(input []byte) []byte { output := make([]byte, len(input)*2) for i := 0; i < len(input); i += 2 { output[i*2], output[i*2+1] = input[i], input[i+1] output[i*2+2], output[i*2+3] = input[i], input[i+1] } return output } func convert16bitStereoTo16bitMono(data []byte) []byte { values := int16Stream(data) data = data[:len(data)/2] // halve the slice size for i := 0; i < len(data); i += 2 { data[i], data[i+1] = int16toBytes(values()/2 + values()/2) } return data } func int16Stream(data []byte) func() int16 { return func() int16 { lo, hi := uint16(data[0]), uint16(data[1]) data = data[2:] return int16(lo | (hi << 8)) } } func int16toBytes(i int16) (lo, hi byte) { return byte(i & 0xFF), byte((i >> 8) % 0xFF) } func convert16bitStereoFrequencies(input []byte, inputFreq, outputFreq int) []byte { if len(input) == 0 { return nil } inLeft, inRight := split2Stereo16bitChannelsToFloats(input) ratio := float64(outputFreq) / float64(inputFreq) outputSampleCount := int(float64(len(inLeft))*ratio + 0.5) out := make([]float32, outputSampleCount*2) outLeft, outRight := out[:len(out)/2], out[len(out)/2:] outLeft[0] = inLeft[0] outRight[0] = inRight[0] outLeft[len(outLeft)-1] = inLeft[len(inLeft)-1] outRight[len(outRight)-1] = inRight[len(inRight)-1] var inputSampleIndexDelta float64 inputSampleIndexDelta = float64(len(inLeft)-1) / float64(len(outLeft)-1) inputSampleIndex := inputSampleIndexDelta for i := 1; i < len(outLeft)-1; i++ { intPart, floatPart := math.Modf(inputSampleIndex) index := int(intPart + 0.5) f := float32(floatPart) outLeft[i] = inLeft[index]*(1.0-f) + inLeft[index+1]*f outRight[i] = inRight[index]*(1.0-f) + inRight[index+1]*f inputSampleIndex += inputSampleIndexDelta } return mergeFloatChannels(outLeft, outRight) } func split2Stereo16bitChannelsToFloats(samples []byte) (left, right []float32) { result := make([]float32, len(samples)/2) left = result[:len(result)/2] right = result[len(result)/2:] i, o := 0, 0 for o < len(left) { lo, hi := uint16(samples[i]), uint16(samples[i+1]) left[o] = float32(int16(lo | (hi << 8))) lo, hi = uint16(samples[i+2]), uint16(samples[i+3]) right[o] = float32(int16(lo | (hi << 8))) i += 4 o++ } return } // mergeFloatChannels assumes that len(left) == len(right) func mergeFloatChannels(left, right []float32) []byte { result := make([]byte, len(left)*4) i, o := 0, 0 for i < len(left) { in := roundToInt16(left[i]) lo, hi := (in & 0xFF), (in>>8)&0xFF result[o], result[o+1] = byte(lo), byte(hi) in = roundToInt16(right[i]) lo, hi = (in & 0xFF), (in>>8)&0xFF result[o+2], result[o+3] = byte(lo), byte(hi) i++ o += 4 } return result } func roundToInt16(f float32) int16 { if f >= 0 { return int16(f + 0.5) } return int16(f - 0.5) }
wav/resample.go
0.73412
0.449634
resample.go
starcoder
// Copyright 2017 Microsoft Corporation. All rights reserved. // Use of this source code is governed by an MIT // license that can be found in the LICENSE file. /* Package azblob can access an Azure Blob Storage. The azblob package is capable of :- - Creating, deleting, and querying containers in an account - Creating, deleting, and querying blobs in a container - Creating Shared Access Signature for authentication Types of Resources The azblob package allows you to interact with three types of resources :- * Azure storage accounts. * Containers within those storage accounts. * Blobs (block blobs/ page blobs/ append blobs) within those containers. The Azure Blob Storage (azblob) client library for Go allows you to interact with each of these components through the use of a dedicated client object. To create a client object, you will need the account's blob service endpoint URL and a credential that allows you to access the account. Types of Credentials The clients support different forms of authentication. The azblob library supports any of the `azcore.TokenCredential` interfaces, authorization via a Connection String, or authorization with a Shared Access Signature token. Using a Shared Key To use an account shared key (aka account key or access key), provide the key as a string. This can be found in your storage account in the Azure Portal under the "Access Keys" section. Use the key as the credential parameter to authenticate the client: accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } accountKey, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_KEY") if !ok { panic("AZURE_STORAGE_ACCOUNT_KEY could not be found") } credential, err := NewSharedKeyCredential(accountName, accountKey) handle(err) serviceClient, err := azblob.NewServiceClient("https://<my_account_name>.blob.core.windows.net/", cred, nil) handle(err) Using a Connection String Depending on your use case and authorization method, you may prefer to initialize a client instance with a connection string instead of providing the account URL and credential separately. To do this, pass the connection string to the service client's `NewServiceClientFromConnectionString` method. The connection string can be found in your storage account in the Azure Portal under the "Access Keys" section. connStr := "DefaultEndpointsProtocol=https;AccountName=<my_account_name>;AccountKey=<my_account_key>;EndpointSuffix=core.windows.net" serviceClient, err := azblob.NewServiceClientFromConnectionString(connStr, nil) Using a Shared Access Signature (SAS) Token To use a shared access signature (SAS) token, provide the token at the end of your service URL. You can generate a SAS token from the Azure Portal under Shared Access Signature or use the ServiceClient.GetSASToken() functions. accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") } accountKey, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_KEY") if !ok { panic("AZURE_STORAGE_ACCOUNT_KEY could not be found") } credential, err := azblob.NewSharedKeyCredential(accountName, accountKey) handle(err) serviceClient, err := azblob.NewServiceClient(fmt.Sprintf("https://%s.blob.core.windows.net/", accountName), credential, nil) handle(err) // Provide the convenience function with relevant info accountSAS, err := serviceClient.GetSASToken(AccountSASResourceTypes{Object: true, Service: true, Container: true}, AccountSASPermissions{Read: true, List: true}, AccountSASServices{Blob: true}, time.Now(), time.Now().Add(48*time.Hour)) handle(err) urlToSend := fmt.Sprintf("https://%s.blob.core.windows.net/?%s", accountName, accountSAS) // You can hand off this URL to someone else via any mechanism you choose. // ****************************************** // When someone receives the URL, they can access the resource using it in code like this, or a tool of some variety. serviceClient, err = azblob.NewServiceClient(urlToSend, azcore.NewAnonymousCredential(), nil) handle(err) // You can also break a blob URL up into its constituent parts blobURLParts := azblob.NewBlobURLParts(serviceClient.URL()) fmt.Printf("SAS expiry time = %s\n", blobURLParts.SAS.ExpiryTime()) Types of Clients There are three different clients provided to interact with the various components of the Blob Service: 1. **`ServiceClient`** * Get and set account settings. * Query, create, and delete containers within the account. 2. **`ContainerClient`** * Get and set container access settings, properties, and metadata. * Create, delete, and query blobs within the container. * `ContainerLeaseClient` to support container lease management. 3. **`BlobClient`** * `AppendBlobClient`, `BlockBlobClient`, and `PageBlobClient` * Get and set blob properties. * Perform CRUD operations on a given blob. * `BlobLeaseClient` to support blob lease management. Examples // Use your storage account's name and key to create a credential object, used to access your account. // You can obtain these details from the Azure Portal. accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { handle(errors.New("AZURE_STORAGE_ACCOUNT_NAME could not be found")) } accountKey, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_KEY") if !ok { handle(errors.New("AZURE_STORAGE_ACCOUNT_KEY could not be found")) } cred, err := NewSharedKeyCredential(accountName, accountKey) handle(err) // Open up a service client. // You'll need to specify a service URL, which for blob endpoints usually makes up the syntax http(s)://<account>.blob.core.windows.net/ service, err := NewServiceClient(fmt.Sprintf("https://%s.blob.core.windows.net/", accountName), cred, nil) handle(err) // All operations in the Azure Blob Storage SDK for Go operate on a context.Context, allowing you to control cancellation/timeout. ctx := context.Background() // This example has no expiry. // This example showcases several common operations to help you get started, such as: // ===== 1. Creating a container ===== // First, branch off of the service client and create a container client. container := service.NewContainerClient("mycontainer") // Then, fire off a create operation on the container client. // Note that, all service-side requests have an options bag attached, allowing you to specify things like metadata, public access types, etc. // Specifying nil omits all options. _, err = container.Create(ctx, nil) handle(err) // ===== 2. Uploading/downloading a block blob ===== // We'll specify our data up-front, rather than reading a file for simplicity's sake. data := "Hello world!" // Branch off of the container into a block blob client blockBlob := container.NewBlockBlobClient("HelloWorld.txt") // Upload data to the block blob _, err = blockBlob.Upload(ctx, NopCloser(strings.NewReader(data)), nil) handle(err) // Download the blob's contents and ensure that the download worked properly get, err := blockBlob.Download(ctx, nil) handle(err) // Open a buffer, reader, and then download! downloadedData := &bytes.Buffer{} reader := get.Body(RetryReaderOptions{}) // RetryReaderOptions has a lot of in-depth tuning abilities, but for the sake of simplicity, we'll omit those here. _, err = downloadedData.ReadFrom(reader) handle(err) err = reader.Close() handle(err) if data != downloadedData.String() { handle(errors.New("downloaded data doesn't match uploaded data")) } // ===== 3. list blobs ===== // The ListBlobs and ListContainers APIs return two channels, a values channel, and an errors channel. // You should enumerate on a range over the values channel, and then check the errors channel, as only ONE value will ever be passed to the errors channel. // The AutoPagerTimeout defines how long it will wait to place into the items channel before it exits & cleans itself up. A zero time will result in no timeout. pager := container.ListBlobsFlat(nil) for pager.NextPage(ctx) { resp := pager.PageResponse() for _, v := range resp.ContainerListBlobFlatSegmentResult.Segment.BlobItems { fmt.Println(*v.Name) } } if err = pager.Err(); err != nil { handle(err) } // Delete the blob we created earlier. _, err = blockBlob.Delete(ctx, nil) handle(err) // Delete the container we created earlier. _, err = container.Delete(ctx, nil) handle(err) */ package azblob
sdk/storage/azblob/doc.go
0.769167
0.42656
doc.go
starcoder
package f32 import "fmt" // A Mat4 is a 4x4 matrix of float32 values. // Elements are indexed first by row then column, i.e. m[row][column]. type Mat4 [4]Vec4 func (m Mat4) String() string { return fmt.Sprintf(`Mat4[% 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f, % 0.3f]`, m[0][0], m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3], m[2][0], m[2][1], m[2][2], m[2][3], m[3][0], m[3][1], m[3][2], m[3][3]) } func (m *Mat4) Identity() { *m = Mat4{ {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, } } func (m *Mat4) Eq(n *Mat4, epsilon float32) bool { for i := range m { for j := range m[i] { diff := m[i][j] - n[i][j] if diff < -epsilon || +epsilon < diff { return false } } } return true } // Mul stores a × b in m. func (m *Mat4) Mul(a, b *Mat4) { // Store the result in local variables, in case m == a || m == b. m00 := a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0] + a[0][3]*b[3][0] m01 := a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1] + a[0][3]*b[3][1] m02 := a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2] + a[0][3]*b[3][2] m03 := a[0][0]*b[0][3] + a[0][1]*b[1][3] + a[0][2]*b[2][3] + a[0][3]*b[3][3] m10 := a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0] + a[1][3]*b[3][0] m11 := a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1] + a[1][3]*b[3][1] m12 := a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2] + a[1][3]*b[3][2] m13 := a[1][0]*b[0][3] + a[1][1]*b[1][3] + a[1][2]*b[2][3] + a[1][3]*b[3][3] m20 := a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0] + a[2][3]*b[3][0] m21 := a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1] + a[2][3]*b[3][1] m22 := a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2] + a[2][3]*b[3][2] m23 := a[2][0]*b[0][3] + a[2][1]*b[1][3] + a[2][2]*b[2][3] + a[2][3]*b[3][3] m30 := a[3][0]*b[0][0] + a[3][1]*b[1][0] + a[3][2]*b[2][0] + a[3][3]*b[3][0] m31 := a[3][0]*b[0][1] + a[3][1]*b[1][1] + a[3][2]*b[2][1] + a[3][3]*b[3][1] m32 := a[3][0]*b[0][2] + a[3][1]*b[1][2] + a[3][2]*b[2][2] + a[3][3]*b[3][2] m33 := a[3][0]*b[0][3] + a[3][1]*b[1][3] + a[3][2]*b[2][3] + a[3][3]*b[3][3] m[0][0] = m00 m[0][1] = m01 m[0][2] = m02 m[0][3] = m03 m[1][0] = m10 m[1][1] = m11 m[1][2] = m12 m[1][3] = m13 m[2][0] = m20 m[2][1] = m21 m[2][2] = m22 m[2][3] = m23 m[3][0] = m30 m[3][1] = m31 m[3][2] = m32 m[3][3] = m33 } // Perspective sets m to be the GL perspective matrix. func (m *Mat4) Perspective(fov Radian, aspect, near, far float32) { t := Tan(float32(fov) / 2) m[0][0] = 1 / (aspect * t) m[1][1] = 1 / t m[2][2] = -(far + near) / (far - near) m[2][3] = -1 m[3][2] = -2 * far * near / (far - near) } // Scale sets m to be a scale followed by p. // It is equivalent to // m.Mul(p, &Mat4{ // {x, 0, 0, 0}, // {0, y, 0, 0}, // {0, 0, z, 0}, // {0, 0, 0, 1}, // }). func (m *Mat4) Scale(p *Mat4, x, y, z float32) { m[0][0] = p[0][0] * x m[0][1] = p[0][1] * y m[0][2] = p[0][2] * z m[0][3] = p[0][3] m[1][0] = p[1][0] * x m[1][1] = p[1][1] * y m[1][2] = p[1][2] * z m[1][3] = p[1][3] m[2][0] = p[2][0] * x m[2][1] = p[2][1] * y m[2][2] = p[2][2] * z m[2][3] = p[2][3] m[3][0] = p[3][0] * x m[3][1] = p[3][1] * y m[3][2] = p[3][2] * z m[3][3] = p[3][3] } // Translate sets m to be a translation followed by p. // It is equivalent to // m.Mul(p, &Mat4{ // {1, 0, 0, x}, // {0, 1, 0, y}, // {0, 0, 1, z}, // {0, 0, 0, 1}, // }). func (m *Mat4) Translate(p *Mat4, x, y, z float32) { m[0][0] = p[0][0] m[0][1] = p[0][1] m[0][2] = p[0][2] m[0][3] = p[0][0]*x + p[0][1]*y + p[0][2]*z + p[0][3] m[1][0] = p[1][0] m[1][1] = p[1][1] m[1][2] = p[1][2] m[1][3] = p[1][0]*x + p[1][1]*y + p[1][2]*z + p[1][3] m[2][0] = p[2][0] m[2][1] = p[2][1] m[2][2] = p[2][2] m[2][3] = p[2][0]*x + p[2][1]*y + p[2][2]*z + p[2][3] m[3][0] = p[3][0] m[3][1] = p[3][1] m[3][2] = p[3][2] m[3][3] = p[3][0]*x + p[3][1]*y + p[3][2]*z + p[3][3] } // Rotate sets m to a rotation in radians around a specified axis, followed by p. // It is equivalent to m.Mul(p, affineRotation). func (m *Mat4) Rotate(p *Mat4, angle Radian, axis *Vec3) { a := *axis a.Normalize() c, s := Cos(float32(angle)), Sin(float32(angle)) d := 1 - c m.Mul(p, &Mat4{{ c + d*a[0]*a[1], 0 + d*a[0]*a[1] + s*a[2], 0 + d*a[0]*a[1] - s*a[1], 0, }, { 0 + d*a[1]*a[0] - s*a[2], c + d*a[1]*a[1], 0 + d*a[1]*a[2] + s*a[0], 0, }, { 0 + d*a[2]*a[0] + s*a[1], 0 + d*a[2]*a[1] - s*a[0], c + d*a[2]*a[2], 0, }, { 0, 0, 0, 1, }}) } func (m *Mat4) LookAt(eye, center, up *Vec3) { f, s, u := new(Vec3), new(Vec3), new(Vec3) *f = *center f.Sub(f, eye) f.Normalize() s.Cross(f, up) s.Normalize() u.Cross(s, f) *m = Mat4{ {s[0], u[0], -f[0], 0}, {s[1], u[1], -f[1], 0}, {s[2], u[2], -f[2], 0}, {-s.Dot(eye), -u.Dot(eye), +f.Dot(eye), 1}, } }
vendor/github.com/fyne-io/mobile/exp/f32/mat4.go
0.575946
0.586079
mat4.go
starcoder
package query import "fmt" type bucketizer string var ( // BUCKETIZERS // BucketizerSum computes the sum of all the values found in the interval to bucketize BucketizerSum bucketizer = "bucketizer.sum" // BucketizerMax returns the max of all the values found on the interval to bucketize BucketizerMax bucketizer = "bucketizer.max" // BucketizerMin returns the min of all the values found in the interval to bucketize BucketizerMin bucketizer = "bucketizer.min" // BucketizerMean returns the mean of all the values found in the interval to bucketize BucketizerMean bucketizer = "bucketizer.mean" // BucketizerMeanCircular push a mapper onto the stack which can then be used to compute the circular mean of all the values found in each sliding window BucketizerMeanCircular = func(i float64) bucketizer { return bucketizer(fmt.Sprintf("%f bucketizer.mean.circular", i)) } // BucketizerMeanCircularExcludeNulls push a mapper onto the stack which can then be used to compute the circular mean of all the values found in each sliding window. The associated location is the centroid of all the encountered locations. The associated elevation is the mean of the encountered elevations BucketizerMeanCircularExcludeNulls = func(i float64) bucketizer { return bucketizer(fmt.Sprintf("%f bucketizer.mean.circular.exclude-nulls", i)) } // BucketizerFirst returns the first value of the interval to bucketize with its associated location and elevation BucketizerFirst bucketizer = "bucketizer.first" // BucketizerLast returns the last value of the interval to bucketize with its associated location and elevation BucketizerLast bucketizer = "bucketizer.last" // BucketizerJoin outputs for the interval to bucketize of the Geo Time SeriesTM the concatenation of the string representation of values separated by the join string BucketizerJoin = func(s string) bucketizer { return bucketizer(fmt.Sprintf("'%s' bucketizer.join", s)) } // BucketizerMedian returns the median of all the values found in the interval to bucketize BucketizerMedian bucketizer = "bucketizer.median" // BucketizerCount computes the number of non-null values found in the interval to bucketize BucketizerCount bucketizer = "bucketizer.count" // BucketizerAnd applies the logical operator AND on all the values found in the interval to bucketize BucketizerAnd bucketizer = "bucketizer.and" // BucketizerOr applies the logical operator OR on all the values found in the interval to bucketize BucketizerOr bucketizer = "bucketizer.or" )
query/bucketizers.go
0.801315
0.410638
bucketizers.go
starcoder
package rtc import ( "log" ) // Group creates a group of objects at the origin. // It implements the Object interface. func Group(shapes ...Object) *GroupT { g := &GroupT{Shape: Shape{Transform: M4Identity(), Material: GetMaterial()}, bounds: Bounds()} g.AddChild(shapes...) return g } // AddChild adds shape(s) to a group. func (g *GroupT) AddChild(shapes ...Object) { g.Children = append(g.Children, shapes...) for _, child := range shapes { child.SetParent(g) UpdateTransformedBounds(child, g.bounds) } } // GroupT represents a group of objects with its own transformation matrix. // It implements the Object interface. type GroupT struct { Shape Children []Object bounds *BoundsT } var _ Object = &GroupT{} // SetTransform sets the object's transform 4x4 matrix. func (g *GroupT) SetTransform(m M4) Object { g.Transform = m return g } // SetMaterial sets the object's material. func (g *GroupT) SetMaterial(material MaterialT) Object { g.Material = material return g } // SetParent sets the object's parent object. func (g *GroupT) SetParent(parent Object) Object { g.Parent = parent return g } // Bounds returns the minimum bounding box of the object in object // (untransformed) space. func (g *GroupT) Bounds() *BoundsT { return g.bounds } // LocalIntersect returns a slice of IntersectionT values where the // transformed (object space) ray intersects the object. func (g *GroupT) LocalIntersect(ray RayT) []IntersectionT { b := g.Bounds() if xs := b.LocalIntersect(ray, g); len(xs) == 0 { return nil } var xs []IntersectionT for _, child := range g.Children { xs = append(xs, Intersect(child, ray)...) } return Intersections(xs...) // sort them } // LocalNormalAt returns the normal vector at the given point of intersection // (transformed to object space) with the object. func (g *GroupT) LocalNormalAt(objectPoint Tuple, hit *IntersectionT) Tuple { log.Fatalf("programming error - groups are abstract and do not have normals") return Tuple{} } // Includes returns whether this object includes (or actually is) the // other object. func (g *GroupT) Includes(other Object) bool { for _, child := range g.Children { if child.Includes(other) { return true } } return false }
rtc/group.go
0.863909
0.411584
group.go
starcoder
package commands import ( "bytes" "fmt" "reflect" "regexp" "strconv" "strings" ) func stringValue(primitive reflect.Value) (string, error) { switch primitive.Kind() { case reflect.Int: fallthrough case reflect.Int8: fallthrough case reflect.Int16: fallthrough case reflect.Int32: fallthrough case reflect.Int64: return strconv.FormatInt(primitive.Int(), 10), nil case reflect.Uint: fallthrough case reflect.Uint8: fallthrough case reflect.Uint16: fallthrough case reflect.Uint32: fallthrough case reflect.Uint64: return strconv.FormatUint(primitive.Uint(), 10), nil case reflect.Float32: fallthrough case reflect.Float64: return strconv.FormatFloat(primitive.Float(), 'f', 5, 64), nil case reflect.String: return primitive.String(), nil default: return "", fmt.Errorf("unsupported type %s", primitive.Kind().String()) } } func containsQuery(val reflect.Value, query string, depth, maxDepth int) bool { if depth >= maxDepth { return false } switch val.Kind() { case reflect.Ptr: return containsQuery(val.Elem(), query, depth, maxDepth) case reflect.Array: fallthrough case reflect.Slice: for i := 0; i < val.Len(); i++ { item := val.Index(i) if containsQuery(item, query, depth+1, maxDepth) { return true } } case reflect.Map: for _, key := range val.MapKeys() { item := val.MapIndex(key) if containsQuery(item, query, depth+1, maxDepth) { return true } } case reflect.Struct: if regexp.MustCompile("^\\d+$").MatchString(query) { idField := val.FieldByName("Id") if idField.IsValid() { return strconv.FormatUint(idField.Uint(), 10) == query } return false } for i := 0; i < val.NumField(); i++ { field := val.Field(i) if containsQuery(field, query, depth+1, maxDepth) { return true } } default: str, err := stringValue(val) if err != nil { return false } return strings.Contains(strings.ToLower(str), query) } return false } func filter(items interface{}, query string, maxDepth int) (interface{}, error) { query = strings.ToLower(query) val := reflect.ValueOf(items) if val.Kind() != reflect.Array && val.Kind() != reflect.Slice { return nil, fmt.Errorf("value must be of type array or slice, %s given", val.Kind().String()) } result := reflect.New(val.Type()).Elem() for i := 0; i < val.Len(); i++ { item := val.Index(i) if containsQuery(item, query, 0, maxDepth) { result = reflect.Append(result, item) } } return result.Interface(), nil } func findOne(items interface{}, query string, maxDepth int) (interface{}, error) { filtered, err := filter(items, query, maxDepth) if err != nil { return nil, err } val := reflect.ValueOf(filtered) if val.Len() == 0 { return nil, fmt.Errorf("no value found matching query %q", query) } if val.Len() > 1 { buf := &bytes.Buffer{} for i := 0; i < val.Len() && i < 3; i++ { buf.WriteString(fmt.Sprintf("%v", val.Index(i).Interface())) if i+1 < val.Len() { buf.WriteString(", ") } } if val.Len() > 3 { buf.WriteString("...") } return nil, fmt.Errorf("more than one matching result were found through query %q: %s", query, buf.String()) } return val.Index(0).Interface(), nil }
internal/commands/filter.go
0.57821
0.466177
filter.go
starcoder
package colorrange import ( "image/color" "github.com/200sc/go-dist/intrange" ) // Linear64 color ranges return colors on a linear distribution type Linear64 struct { r, g, b, a intrange.Range } // NewLinear64 returns a linear color distribution between min and maxColor func NewLinear64(minColor, maxColor color.Color) Range { r, g, b, a := minColor.RGBA() r2, g2, b2, a2 := maxColor.RGBA() return Linear64{ intrange.NewLinear(int(r), int(r2)), intrange.NewLinear(int(g), int(g2)), intrange.NewLinear(int(b), int(b2)), intrange.NewLinear(int(a), int(a2)), } } // EnforceRange rounds the input color's components so that they fall in the // given range. func (l Linear64) EnforceRange(c color.Color) color.Color { r3, g3, b3, a3 := c.RGBA() r4 := l.r.EnforceRange(int(r3)) g4 := l.g.EnforceRange(int(g3)) b4 := l.b.EnforceRange(int(b3)) a4 := l.a.EnforceRange(int(a3)) return color.RGBA64{uint16(r4), uint16(g4), uint16(b4), uint16(a4)} } // InRange returns whether the input color falls in this range func (l Linear64) InRange(c color.Color) bool { r3, g3, b3, a3 := c.RGBA() return l.r.InRange(int(r3)) && l.g.InRange(int(g3)) && l.b.InRange(int(b3)) && l.a.InRange(int(a3)) } // Poll returns a randomly chosen color in the bounds of this color range func (l Linear64) Poll() color.Color { r3 := l.r.Poll() g3 := l.g.Poll() b3 := l.b.Poll() a3 := l.a.Poll() return color.RGBA64{uint16(r3), uint16(g3), uint16(b3), uint16(a3)} } // Percentile returns a color f percent along the color range func (l Linear64) Percentile(f float64) color.Color { r3 := l.r.Percentile(f) g3 := l.g.Percentile(f) b3 := l.b.Percentile(f) a3 := l.a.Percentile(f) return color.RGBA64{uint16(r3), uint16(g3), uint16(b3), uint16(a3)} } // Linear color ranges return colors on a linear distribution type Linear struct { r, g, b, a intrange.Range } // NewLinear returns a linear color distribution between min and maxColor func NewLinear(minColor, maxColor color.Color) Range { r, g, b, a := minColor.RGBA() r2, g2, b2, a2 := maxColor.RGBA() return Linear{ intrange.NewLinear(int(r), int(r2)), intrange.NewLinear(int(g), int(g2)), intrange.NewLinear(int(b), int(b2)), intrange.NewLinear(int(a), int(a2)), } } // EnforceRange rounds the input color's components so that they fall in the // given range. func (l Linear) EnforceRange(c color.Color) color.Color { r3, g3, b3, a3 := c.RGBA() r4 := l.r.EnforceRange(int(r3)) g4 := l.g.EnforceRange(int(g3)) b4 := l.b.EnforceRange(int(b3)) a4 := l.a.EnforceRange(int(a3)) return rgbaFromInts(r4, g4, b4, a4) } // InRange returns whether the input color falls in this range func (l Linear) InRange(c color.Color) bool { r3, g3, b3, a3 := c.RGBA() return l.r.InRange(int(r3)) && l.g.InRange(int(g3)) && l.b.InRange(int(b3)) && l.a.InRange(int(a3)) } // Poll returns a randomly chosen color in the bounds of this color range func (l Linear) Poll() color.Color { r3 := l.r.Poll() g3 := l.g.Poll() b3 := l.b.Poll() a3 := l.a.Poll() return rgbaFromInts(r3, g3, b3, a3) } // Percentile returns a color f percent along the color range func (l Linear) Percentile(f float64) color.Color { r3 := l.r.Percentile(f) g3 := l.g.Percentile(f) b3 := l.b.Percentile(f) a3 := l.a.Percentile(f) return rgbaFromInts(r3, g3, b3, a3) } func rgbaFromInts(r, g, b, a int) color.RGBA { return color.RGBA{uint8(r / 257), uint8(g / 257), uint8(b / 257), uint8(a / 257)} }
colorrange/linear.go
0.920222
0.523055
linear.go
starcoder
package plantest import ( "testing" "github.com/google/go-cmp/cmp" "github.com/influxdata/flux/plan" "github.com/influxdata/flux/semantic/semantictest" "github.com/influxdata/flux/stdlib/influxdata/influxdb" "github.com/influxdata/flux/stdlib/universe" ) // SimpleRule is a simple rule whose pattern matches any plan node and // just stores the NodeIDs of nodes it has visited in SeenNodes. type SimpleRule struct { SeenNodes []plan.NodeID } func (sr *SimpleRule) Pattern() plan.Pattern { return plan.Any() } func (sr *SimpleRule) Rewrite(node plan.PlanNode) (plan.PlanNode, bool, error) { sr.SeenNodes = append(sr.SeenNodes, node.ID()) return node, false, nil } func (sr *SimpleRule) Name() string { return "simple" } // MergeFromRangePhysicalRule merges a from and a subsequent range. type MergeFromRangePhysicalRule struct{} func (sr *MergeFromRangePhysicalRule) Pattern() plan.Pattern { return plan.Pat(universe.RangeKind, plan.Pat(influxdb.FromKind)) } func (sr *MergeFromRangePhysicalRule) Rewrite(node plan.PlanNode) (plan.PlanNode, bool, error) { mergedSpec := node.Predecessors()[0].ProcedureSpec().Copy().(*influxdb.FromProcedureSpec) mergedNode, err := plan.MergeToPhysicalPlanNode(node, node.Predecessors()[0], mergedSpec) if err != nil { return nil, false, err } return mergedNode, true, nil } func (sr *MergeFromRangePhysicalRule) Name() string { return "fromRangeRule" } // SmashPlanRule adds an `Intruder` as predecessor of the given `Node` without // marking it as successor of it. It breaks the integrity of the plan. // If `Kind` is specified, it takes precedence over `Node`, and the rule will use it // to match. type SmashPlanRule struct { Node plan.PlanNode Intruder plan.PlanNode Kind plan.ProcedureKind } func (SmashPlanRule) Name() string { return "SmashPlanRule" } func (spp SmashPlanRule) Pattern() plan.Pattern { var k plan.ProcedureKind if len(spp.Kind) > 0 { k = spp.Kind } else { k = spp.Node.Kind() } return plan.Pat(k, plan.Any()) } func (spp SmashPlanRule) Rewrite(node plan.PlanNode) (plan.PlanNode, bool, error) { var changed bool if len(spp.Kind) > 0 || node == spp.Node { node.AddPredecessors(spp.Intruder) changed = true } // it is not necessary to return a copy of the node, because the rule changes the number // of predecessors and it won't be re-triggered again. return node, changed, nil } // CreateCycleRule creates a cycle between the given `Node` and its predecessor. // It creates exactly one cycle. After the rule is triggered once, it won't have any effect later. // This rule breaks the integrity of the plan. // If `Kind` is specified, it takes precedence over `Node`, and the rule will use it // to match. type CreateCycleRule struct { Node plan.PlanNode Kind plan.ProcedureKind } func (CreateCycleRule) Name() string { return "CreateCycleRule" } func (ccr CreateCycleRule) Pattern() plan.Pattern { var k plan.ProcedureKind if len(ccr.Kind) > 0 { k = ccr.Kind } else { k = ccr.Node.Kind() } return plan.Pat(k, plan.Any()) } func (ccr CreateCycleRule) Rewrite(node plan.PlanNode) (plan.PlanNode, bool, error) { var changed bool if len(ccr.Kind) > 0 || node == ccr.Node { node.Predecessors()[0].AddPredecessors(node) node.AddSuccessors(node.Predecessors()[0]) changed = true } // just return a copy of the node, otherwise the rule will be triggered an infinite number of times // (it doesn't change the number of predecessors, indeed). return node.ShallowCopy(), changed, nil } // RuleTestCase allows for concise creation of test cases that exercise rules type RuleTestCase struct { Name string Rules []plan.Rule Before *PlanSpec After *PlanSpec NoChange bool } // PhysicalRuleTestHelper will run a rule test case. func PhysicalRuleTestHelper(t *testing.T, tc *RuleTestCase) { t.Helper() before := CreatePlanSpec(tc.Before) var after *plan.PlanSpec if tc.NoChange { after = CreatePlanSpec(tc.Before.Copy()) } else { after = CreatePlanSpec(tc.After) } // Disable validation so that we can avoid having to push a range into every from physicalPlanner := plan.NewPhysicalPlanner( plan.OnlyPhysicalRules(tc.Rules...), plan.DisableValidation(), ) pp, err := physicalPlanner.Plan(before) if err != nil { t.Fatal(err) } type testAttrs struct { ID plan.NodeID Spec plan.PhysicalProcedureSpec } want := make([]testAttrs, 0) after.BottomUpWalk(func(node plan.PlanNode) error { want = append(want, testAttrs{ ID: node.ID(), Spec: node.ProcedureSpec().(plan.PhysicalProcedureSpec), }) return nil }) got := make([]testAttrs, 0) pp.BottomUpWalk(func(node plan.PlanNode) error { got = append(got, testAttrs{ ID: node.ID(), Spec: node.ProcedureSpec().(plan.PhysicalProcedureSpec), }) return nil }) if !cmp.Equal(want, got, semantictest.CmpOptions...) { t.Errorf("transformed plan not as expected, -want/+got:\n%v", cmp.Diff(want, got, semantictest.CmpOptions...)) } } // LogicalRuleTestHelper will run a rule test case. func LogicalRuleTestHelper(t *testing.T, tc *RuleTestCase) { t.Helper() before := CreatePlanSpec(tc.Before) var after *plan.PlanSpec if tc.NoChange { after = CreatePlanSpec(tc.Before.Copy()) } else { after = CreatePlanSpec(tc.After) } logicalPlanner := plan.NewLogicalPlanner( plan.OnlyLogicalRules(tc.Rules...), ) pp, err := logicalPlanner.Plan(before) if err != nil { t.Fatal(err) } type testAttrs struct { ID plan.NodeID Spec plan.ProcedureSpec } want := make([]testAttrs, 0) after.BottomUpWalk(func(node plan.PlanNode) error { want = append(want, testAttrs{ ID: node.ID(), Spec: node.ProcedureSpec(), }) return nil }) got := make([]testAttrs, 0) pp.BottomUpWalk(func(node plan.PlanNode) error { got = append(got, testAttrs{ ID: node.ID(), Spec: node.ProcedureSpec(), }) return nil }) if !cmp.Equal(want, got, semantictest.CmpOptions...) { t.Errorf("transformed plan not as expected, -want/+got:\n%v", cmp.Diff(want, got, semantictest.CmpOptions...)) } }
plan/plantest/rules.go
0.717705
0.432243
rules.go
starcoder
package window import ( "fmt" "strconv" "strings" "time" "github.com/cockroachdb/errors" ) type rate struct { n int unit rateUnit } func makeUnlimitedRate() rate { return rate{n: -1} } func (r rate) IsUnlimited() bool { return r.n == -1 } type rateUnit int const ( ratePerSecond = iota ratePerMinute ratePerHour ) func (ru rateUnit) AsDuration() time.Duration { switch ru { case ratePerSecond: return time.Second case ratePerMinute: return time.Minute case ratePerHour: return time.Hour default: panic(fmt.Sprintf("invalid rateUnit value: %v", ru)) } } func parseRateUnit(raw string) (rateUnit, error) { // We're not going to replicate the full schema validation regex here; we'll // assume that the conf package did that satisfactorily and just parse what // we need to, ensuring we can't panic. if raw == "" { return ratePerSecond, errors.Errorf("malformed unit: %q", raw) } switch raw[0] { case 's', 'S': return ratePerSecond, nil case 'm', 'M': return ratePerMinute, nil case 'h', 'H': return ratePerHour, nil default: return ratePerSecond, errors.Errorf("malformed unit: %q", raw) } } // parseRate parses a rate given either as a raw integer (which will be // interpreted as a rate per second), a string "unlimited" (which will be // interpreted, surprisingly, as unlimited), or a string in the form "N/UNIT". func parseRate(raw interface{}) (rate, error) { switch v := raw.(type) { case int: if v == 0 { return rate{n: 0}, nil } return rate{}, errors.Errorf("malformed rate (numeric values can only be 0): %d", v) case string: s := strings.ToLower(v) if s == "unlimited" { return rate{n: -1}, nil } wr := rate{} parts := strings.SplitN(s, "/", 2) if len(parts) != 2 { return rate{}, errors.Errorf("malformed rate: %q", raw) } var err error wr.n, err = strconv.Atoi(parts[0]) if err != nil || wr.n < 0 { return wr, errors.Errorf("malformed rate: %q", raw) } wr.unit, err = parseRateUnit(parts[1]) if err != nil { return wr, errors.Errorf("malformed rate: %q", raw) } return wr, nil default: return rate{}, errors.Errorf("malformed rate: unknown type %T", raw) } }
enterprise/internal/batches/types/scheduler/window/rate.go
0.688364
0.402245
rate.go
starcoder
package uncertainty // numCompareSamples is the number of samples to materialize to generate a comparison. // Follows the paper in choice of value. // TODO(barakmich): maybe worth exposing in some broader way. const numCompareSamples = 10_000 type compareFunc func(x float64, y float64) bool type comparisonOperation struct { a, b Uncertain i int comparer compareFunc } // TODO(barakmich): These comparisons do a simple sampling comparison by // default, however, as an extension for speed and correctness, it's relatively // straightforward to type-inspect the uncertainty types and create a // better/faster/more-accruate implementation that matches. // LessThan returns a Bernoulli distribution // where the probability of a 1.0 is reflected by // how often a < b. func LessThan(a Uncertain, b Uncertain) UncertainBool { return newComparison(a, b, func(x, y float64) bool { return x < y }) } func GreaterThan(a Uncertain, b Uncertain) UncertainBool { return newComparison(a, b, func(x, y float64) bool { return x > y }) } func NotEquals(a Uncertain, b Uncertain) UncertainBool { return newComparison(a, b, func(x, y float64) bool { return x != y }) } func Equals(a Uncertain, b Uncertain) UncertainBool { return newComparison(a, b, func(x, y float64) bool { return x == y }) } func newComparison(a Uncertain, b Uncertain, compare compareFunc) *comparisonOperation { return &comparisonOperation{ a: a, b: b, i: newID(), comparer: compare, } } func (comp *comparisonOperation) sampleBool() bool { return comp.comparer(comp.a.sample(), comp.b.sample()) } func (comp *comparisonOperation) sample() float64 { return convertBoolSampleToFloat(comp.sampleBool()) } func (comp *comparisonOperation) id() int { return comp.i } func (comp *comparisonOperation) sampleWithTrace() *sample { asample := comp.a.sampleWithTrace() bsample := comp.b.sampleWithTrace() out := asample.combine(bsample) out.value = convertBoolSampleToFloat( comp.comparer( asample.value, bsample.value, ), ) out.addTrace(comp.i, out.value) return out } func (comp *comparisonOperation) Pr() bool { return Pr(comp) }
equality.go
0.546254
0.701656
equality.go
starcoder
package timebox import ( "time" ) //Set is a container with zero or more slots in it. Slots in a set may overlap each other. //You can use the set to calculate lanes from the slots inside. type Set struct { slots []*Slot } //NewSet creates a new set. func NewSet() *Set { return &Set{} } //Add adds a new slot to a set. //The slot is passed as a pointer that is stored in the set, so be aware that later changes to the slot affect the set. func (s *Set) Add(slot *Slot) { s.slots = append(s.slots, slot) } //Slots returns a slice of the slots in a set. Be aware that changes to the returned slots affect the set. func (s *Set) Slots() []*Slot { return s.slots } //Find returns a slice of all slots in the set satisfying f(slot), or an empty slice if none do. //Be aware that any changes to the returned slots affect the set. func (s *Set) Find(f func(*Slot) bool) []*Slot { results := []*Slot{} for _, slot := range s.slots { if f(slot) { results = append(results, slot) } } return results } //Any returns whether any slot in the set satisfies f(slot). func (s *Set) Any(f func(*Slot) bool) bool { for _, slot := range s.slots { if f(slot) { return true } } return false } //All returns whether any slot in the set satisfies f(slot). func (s *Set) All(f func(*Slot) bool) bool { for _, slot := range s.slots { if !f(slot) { return false } } return true } //Contains returns whether any slot in the set contains a given time. func (s *Set) Contains(t time.Time) bool { return s.Any(func(slot *Slot) bool { return slot.Contains(t) }) } //Overlaps returns whether any slot in the set overlaps a given other slot. func (s *Set) Overlaps(slot *Slot) bool { return s.Any(func(sl *Slot) bool { return sl.Overlaps(slot) }) } //SplitLinear distributes the slots in the set to multiple sets in a way that ensures that no set contains multiple overlapping slots. func (s *Set) SplitLinear() []*Set { result := []*Set{} Outer: for _, slotToDistribute := range s.slots { for _, set := range result { if !set.Overlaps(slotToDistribute) { set.Add(slotToDistribute) continue Outer } } newSet := NewSet() newSet.Add(slotToDistribute) result = append(result, newSet) } return result }
set.go
0.789193
0.423637
set.go
starcoder
package source import ( "go/ast" "go/types" ) // builtinArgKind determines the expected object kind for a builtin // argument. It attempts to use the AST hints from builtin.go where // possible. func (c *completer) builtinArgKind(obj types.Object, call *ast.CallExpr) objKind { astObj, err := c.snapshot.View().LookupBuiltin(obj.Name()) if err != nil { return 0 } exprIdx := indexExprAtPos(c.pos, call.Args) decl, ok := astObj.Decl.(*ast.FuncDecl) if !ok || exprIdx >= len(decl.Type.Params.List) { return 0 } switch ptyp := decl.Type.Params.List[exprIdx].Type.(type) { case *ast.ChanType: return kindChan case *ast.ArrayType: return kindSlice case *ast.MapType: return kindMap case *ast.Ident: switch ptyp.Name { case "Type": switch obj.Name() { case "make": return kindChan | kindSlice | kindMap case "len": return kindSlice | kindMap | kindArray | kindString | kindChan case "cap": return kindSlice | kindArray | kindChan } } } return 0 } // builtinArgType infers the type of an argument to a builtin // function. "parentType" is the inferred type for the builtin call's // parent node. func (c *completer) builtinArgType(obj types.Object, call *ast.CallExpr, parentType types.Type) (infType types.Type, variadic bool) { exprIdx := indexExprAtPos(c.pos, call.Args) switch obj.Name() { case "append": // Check if we are completing the variadic append() param. variadic = exprIdx == 1 && len(call.Args) <= 2 infType = parentType // If we are completing an individual element of the variadic // param, "deslice" the expected type. if !variadic && exprIdx > 0 { if slice, ok := parentType.(*types.Slice); ok { infType = slice.Elem() } } case "delete": if exprIdx > 0 && len(call.Args) > 0 { // Try to fill in expected type of map key. firstArgType := c.pkg.GetTypesInfo().TypeOf(call.Args[0]) if firstArgType != nil { if mt, ok := firstArgType.Underlying().(*types.Map); ok { infType = mt.Key() } } } case "copy": var t1, t2 types.Type if len(call.Args) > 0 { t1 = c.pkg.GetTypesInfo().TypeOf(call.Args[0]) if len(call.Args) > 1 { t2 = c.pkg.GetTypesInfo().TypeOf(call.Args[1]) } } // Fill in expected type of either arg if the other is already present. if exprIdx == 1 && t1 != nil { infType = t1 } else if exprIdx == 0 && t2 != nil { infType = t2 } case "new": if parentType != nil { // Expected type for "new" is the de-pointered parent type. if ptr, ok := parentType.Underlying().(*types.Pointer); ok { infType = ptr.Elem() } } case "make": if exprIdx == 0 { infType = parentType } } return infType, variadic }
internal/lsp/source/completion_builtin.go
0.607197
0.444083
completion_builtin.go
starcoder
package intcode import "github.com/afarbos/aoc/pkg/convert" type opcode int // OpCodes enumeration of operation code. const ( // Add paramater 1 and 2 and store it in 3 Add opcode = iota + 1 // Multiply paramater 1 and 2 and store it in 3 Multiply // Input stored at parameter 1 Input // Output the value of parameter 1 Output // JumpTrue at parameter 2 if parameter 1 is non-zero JumpTrue // JumpFalse at parameter 2 if parameter 2 is zero JumpFalse // Less return 1 if parameter 1 is less than 2 else 0 Less // Equals return 1 if parameter 1 is equal to 2 else 0 Equals // Stop the program Stop = 99 ) type program struct { maxOp opcode index int inputs, outputs chan int runners []runner instructions []int } type runner interface { run(p *program, arg1, arg2, arg3 int) bool } type add struct{} type multiply struct{} type input struct{} type output struct{} type jumpTrue struct{} type jumpFalse struct{} type less struct{} type equals struct{} type stop struct{} func newProgram(maxOp opcode, inputs, outputs chan int, instructions []int) *program { return &program{ inputs: inputs, instructions: instructions, maxOp: maxOp, outputs: outputs, runners: []runner{ new(stop), new(add), new(multiply), new(input), new(output), new(jumpTrue), new(jumpFalse), new(less), new(equals), }, } } func (p *program) extractArguments() (op opcode, arg1, arg2, arg3 int) { var ( instruction = p.instructions[p.index] a = instruction % 100000 / 10000 b = instruction % 10000 / 1000 c = instruction % 1000 / 100 ) op = opcode(instruction % 100) if op > p.maxOp || op == 0 { if op != Stop { arg1 = -1 } op = 0 } arg3 = p.index + 3 if a == 0 && arg3 < len(p.instructions) { arg3 = p.instructions[arg3] } arg2 = p.index + 2 if b == 0 && arg2 < len(p.instructions) { arg2 = p.instructions[arg2] } arg1 = p.index + 1 if c == 0 && arg1 < len(p.instructions) { arg1 = p.instructions[arg1] } return op, arg1, arg2, arg3 } func (*add) run(p *program, arg1, arg2, arg3 int) bool { p.index += 4 p.instructions[arg3] = p.instructions[arg1] + p.instructions[arg2] return true } func (*multiply) run(p *program, arg1, arg2, arg3 int) bool { p.index += 4 p.instructions[arg3] = p.instructions[arg1] * p.instructions[arg2] return true } func (*input) run(p *program, arg1, _, _ int) bool { p.index += 2 p.instructions[arg1] = <-p.inputs return true } func (*output) run(p *program, arg1, _, _ int) bool { p.index += 2 p.outputs <- p.instructions[arg1] return true } func (*jumpTrue) run(p *program, arg1, arg2, _ int) bool { p.index += 3 if p.instructions[arg1] != 0 { p.index = p.instructions[arg2] } return true } func (*jumpFalse) run(p *program, arg1, arg2, _ int) bool { p.index += 3 if p.instructions[arg1] == 0 { p.index = p.instructions[arg2] } return true } func (*less) run(p *program, arg1, arg2, arg3 int) bool { p.index += 4 p.instructions[arg3] = convert.Btoi(p.instructions[arg1] < p.instructions[arg2]) return true } func (*equals) run(p *program, arg1, arg2, arg3 int) bool { p.index += 4 p.instructions[arg3] = convert.Btoi(p.instructions[arg1] == p.instructions[arg2]) return true } func (*stop) run(p *program, arg1, _, _ int) bool { if arg1 < 0 { // unknown opcode p.index += 4 return true } // normal stop if p.maxOp < Output { p.outputs <- p.instructions[0] } return false } func (p *program) execute() { var ( shouldContinue = true op opcode arg1, arg2, arg3 int ) for ; shouldContinue; shouldContinue = p.runners[op].run(p, arg1, arg2, arg3) { op, arg1, arg2, arg3 = p.extractArguments() } } // Compute run a set instructions (also called program). func Compute(instructions []int, maxOp opcode, inputs, outputs chan int) { newProgram(maxOp, inputs, outputs, instructions).execute() }
pkg/intcode/intcode.go
0.528777
0.451992
intcode.go
starcoder
package kafkawireformat import ( "hash/crc32" ) type Records interface { } // the length field of a RecordBatch denotes the length of the entire message // this is the byte size of the static "overhead" (the size of the metadata fields) // the number of actual bytes that contain Records (or the payload) of this message // can be calculated by (Length - constantBatchMessageHeaderSize) const constantBatchMessageHeaderSize = 57 type RecordBatch struct { FirstOffset int64 // this is the byte size of this entire RecordBatch Length int32 PartitionLeaderEpoch int32 Magic int8 CRC int32 // lowest three bits contain the compression algorithm used for the message (0 -> none, 1 -> gzip, 2 -> snappy) // the fourth lowest bit represents the timestamp type (1 -> LogAppendType, producers should always set this to 0) // the fith lowest bit indicates whether this record batch is part of a transaction or not (0 -> not transactional, 1 -> transactional) // the sixth lowest bit indicates whether the record batch includes a control message (1 -> contains control message, 0 -> doesn't contain a control message) Attributes int16 LastOffsetDelta int32 FirstTimestamp int64 MaxTimestamp int64 ProducerId int64 ProducerEpoch int16 FirstSequence int32 Records []*Record } func (rb *RecordBatch) Decode(dec *Decoder) error { rb.FirstOffset = dec.ReadInt64() rb.Length = dec.ReadInt32() rb.PartitionLeaderEpoch = dec.ReadInt32() rb.Magic = dec.ReadInt8() rb.CRC = dec.ReadInt32() rb.Attributes = dec.ReadInt16() rb.LastOffsetDelta = dec.ReadInt32() rb.FirstTimestamp = dec.ReadInt64() rb.MaxTimestamp = dec.ReadInt64() rb.ProducerId = dec.ReadInt64() rb.ProducerEpoch = dec.ReadInt16() rb.FirstSequence = dec.ReadInt32() numRecords := dec.ReadInt32() // read all records as raw bytes first recordsAsBytes := dec.ReadRawBytes(int(rb.Length) - constantBatchMessageHeaderSize) innerDec := NewDecoderFromBytes(recordsAsBytes) { if int(numRecords) == -1 { rb.Records = nil } else { buf := make([]*Record, numRecords) var i int32 for i = 0; i < numRecords; i++ { item := new(Record) item.Decode(innerDec) buf[i] = item } rb.Records = buf } } return nil } func (rb *RecordBatch) Encode(enc *Encoder) error { // In order to facilitate byte size calculations, we write all records into their own encoder. // Having a separate encoder will (hopefully) down the road when we' want to build compression. numRecords := int32(len(rb.Records)) recordsEnc := NewEncoder() { for i := int32(0); i < numRecords; i++ { rb.Records[i].Encode(recordsEnc) } } // The crc check sum includes the entire RecordBatch after the crc check sum itself. // That's why we're are writing all fields after that into a different encoder. // This way we'd be passing the content of the entire encoder to the hasher and we're good. crcCheckSumEnc := NewEncoder() crcCheckSumEnc.WriteInt16(rb.Attributes) crcCheckSumEnc.WriteInt32(rb.LastOffsetDelta) crcCheckSumEnc.WriteInt64(rb.FirstTimestamp) crcCheckSumEnc.WriteInt64(rb.MaxTimestamp) crcCheckSumEnc.WriteInt64(rb.ProducerId) crcCheckSumEnc.WriteInt16(rb.ProducerEpoch) crcCheckSumEnc.WriteInt32(rb.FirstSequence) // yes, this is the number of records (not the byte size!!!) crcCheckSumEnc.WriteInt32(numRecords) crcCheckSumEnc.WriteRawBytes(recordsEnc.Bytes()) // write the byte size of the RecordBatch structure first // that'll be my calculation plus these magical 4 bytes enc.WriteInt32(int32(constantBatchMessageHeaderSize + recordsEnc.Len() + 4)) enc.WriteInt64(rb.FirstOffset) // this is the byte size of the remainder of the RecordBatch (basically the size of the message from here on including me [the size int32]) enc.WriteInt32(int32(constantBatchMessageHeaderSize + recordsEnc.Len() - 8)) // this might be -8 (the first offset (8 for the int64) that we skipped) enc.WriteInt32(rb.PartitionLeaderEpoch) enc.WriteInt8(int8(2)) // compute check sum crcCheckSum := crc32.Checksum(crcCheckSumEnc.Bytes(), crc32.MakeTable(crc32.Castagnoli)) enc.WriteInt32(int32(crcCheckSum)) // write the rest of the message enc.WriteRawBytes(crcCheckSumEnc.Bytes()) return nil } type Record struct { // currently unused Attributes int8 TimestampDelta int64 // varint OffsetDelta int64 // varint Key []byte // data Value []byte // data Headers []*Header } func (r *Record) Decode(dec *Decoder) error { // This looks a little different than any other // message because a Record is lead with its byte size // as varint. That means I need to serialize the message // first in order to calculate its byte size. innerDec := NewDecoderFromBytes(dec.ReadVarIntByteArray()) r.Attributes = innerDec.ReadInt8() r.TimestampDelta, _ = innerDec.ReadVarInt() r.OffsetDelta, _ = innerDec.ReadVarInt() r.Key = innerDec.ReadVarIntByteArray() r.Value = innerDec.ReadVarIntByteArray() { arrayLength := innerDec.ReadInt32() if int(arrayLength) == -1 { r.Headers = nil } else { buf := make([]*Header, arrayLength) var i int32 for i = 0; i < arrayLength; i++ { item := new(Header) item.Decode(innerDec) buf[i] = item } r.Headers = buf } } return nil } func (r *Record) Encode(enc *Encoder) error { // This looks a little different than any other // message because a Record is lead with its byte size // as varint. That means I need to serialize the message // first in order to calculate its byte size. innerEnc := NewEncoder() innerEnc.WriteInt8(r.Attributes) innerEnc.WriteVarInt(r.TimestampDelta) innerEnc.WriteVarInt(r.OffsetDelta) innerEnc.WriteVarIntByteArray(r.Key) innerEnc.WriteVarIntByteArray(r.Value) { arrayLength := len(r.Headers) innerEnc.WriteVarInt(int64(arrayLength)) for i := 0; i < arrayLength; i++ { r.Headers[i].Encode(innerEnc) } } enc.WriteVarIntByteArray(innerEnc.Bytes()) return nil } type Header struct { HeaderKey string HeaderValue []byte // this is just bytes -- the consumer needs to figure out what this is } func (h *Header) Decode(dec *Decoder) error { h.HeaderKey = string(dec.ReadVarIntByteArray()) h.HeaderValue = dec.ReadVarIntByteArray() return nil } func (h *Header) Encode(enc *Encoder) error { enc.WriteVarIntByteArray([]byte(h.HeaderKey)) enc.WriteVarIntByteArray(h.HeaderValue) return nil }
src/main/resources/records.go
0.750461
0.460046
records.go
starcoder
package keybinary import ( "encoding/base64" ) const ( expectEncodedByteArray32 = 43 // base64.RawStdEncoding.EncodedLen(32) expectEncodedByteArray64 = 86 // base64.RawStdEncoding.EncodedLen(64) ) var emptyByteArray32 [32]byte var emptyByteArray64 [64]byte // ByteArray32 contain a 32 bytes array. type ByteArray32 struct { a [32]byte } // NewByteArray32 create new instance of ByteArray32 with given array reference. // If arrayRef is nil the resulted instance will have array fill with empty (0/zero) value. func NewByteArray32(arrayRef *[32]byte) (k *ByteArray32) { if arrayRef == nil { k = &ByteArray32{} } else { k = &ByteArray32{ a: *arrayRef, } } return } // Ref return pointer references array. func (k *ByteArray32) Ref() (ref *[32]byte) { ref = &k.a return } // Load copy given array into instance. func (k *ByteArray32) Load(arrayRef *[32]byte) { k.a = *arrayRef } // Clear empty key content. func (k *ByteArray32) Clear() { copy(k.a[:], emptyByteArray32[:]) } // IsZero return is content of array in zero. func (k *ByteArray32) IsZero() bool { return (k.a == emptyByteArray32) } // MarshalBinary implement encoding.BinaryMarshaler interface. func (k *ByteArray32) MarshalBinary() (data []byte, err error) { if k == nil { return } data = make([]byte, 32) copy(data, k.a[:]) return } // UnmarshalBinary implement encoding.BinaryUnmarshaler interface. func (k *ByteArray32) UnmarshalBinary(data []byte) (err error) { if l := len(data); l == 0 { k.Clear() return } else if l != 32 { err = &ErrIncorrectDataSize{ ExpectSize: 32, ReceivedSize: len(data), } return } copy(k.a[:], data) return } // MarshalText implement encoding.TextMarshaler interface. func (k *ByteArray32) MarshalText() (text []byte, err error) { if (k == nil) || (k.a == emptyByteArray32) { return } text = make([]byte, expectEncodedByteArray32) base64.RawStdEncoding.Encode(text, k.a[:]) return } // UnmarshalText implement encoding.TextUnmarshaler interface. func (k *ByteArray32) UnmarshalText(text []byte) (err error) { if l := len(text); l == 0 { k.Clear() return } else if l != expectEncodedByteArray32 { err = &ErrIncorrectDataSize{ ExpectSize: expectEncodedByteArray32, ReceivedSize: l, } return } _, err = base64.RawStdEncoding.Decode(k.a[:], text) return } // String convert k into string. // Resulted string will be base64.RawStdEncoding encoded or empty string if k is nil. func (k *ByteArray32) String() string { buf, _ := k.MarshalText() return string(buf) } // ByteArray64 contain a 64 bytes key. type ByteArray64 struct { a [64]byte } // NewByteArray64 create new instance of ByteArray64 with given key. // If arrayRef is nil the resulted instance will have array fill with empty (0/zero) value. func NewByteArray64(arrayRef *[64]byte) (k *ByteArray64) { if arrayRef == nil { k = &ByteArray64{} } else { k = &ByteArray64{ a: *arrayRef, } } return } // Ref return pointer references array. func (k *ByteArray64) Ref() (ref *[64]byte) { ref = &k.a return } // Load copy given key into instance. func (k *ByteArray64) Load(arrayRef *[64]byte) { k.a = *arrayRef } // Clear empty key content. func (k *ByteArray64) Clear() { copy(k.a[:], emptyByteArray64[:]) } // IsZero return is content of array in zero. func (k *ByteArray64) IsZero() bool { return (k.a == emptyByteArray64) } // MarshalBinary implement encoding.BinaryMarshaler interface. func (k *ByteArray64) MarshalBinary() (data []byte, err error) { if k == nil { return } data = make([]byte, 64) copy(data, k.a[:]) return } // UnmarshalBinary implement encoding.BinaryUnmarshaler interface. func (k *ByteArray64) UnmarshalBinary(data []byte) (err error) { if l := len(data); l == 0 { k.Clear() return } else if l != 64 { err = &ErrIncorrectDataSize{ ExpectSize: 64, ReceivedSize: len(data), } return } copy(k.a[:], data) return } // MarshalText implement encoding.TextMarshaler interface. func (k *ByteArray64) MarshalText() (text []byte, err error) { if (k == nil) || (k.a == emptyByteArray64) { return } text = make([]byte, expectEncodedByteArray64) base64.RawStdEncoding.Encode(text, k.a[:]) return } // UnmarshalText implement encoding.TextUnmarshaler interface. func (k *ByteArray64) UnmarshalText(text []byte) (err error) { if l := len(text); l == 0 { k.Clear() return } else if l != expectEncodedByteArray64 { err = &ErrIncorrectDataSize{ ExpectSize: expectEncodedByteArray64, ReceivedSize: l, } return } _, err = base64.RawStdEncoding.Decode(k.a[:], text) return } // String convert k into string. // Resulted string will be base64.RawStdEncoding encoded or empty string if k is nil. func (k *ByteArray64) String() string { buf, _ := k.MarshalText() return string(buf) }
bytearray.go
0.773302
0.50061
bytearray.go
starcoder
package openapi import ( "encoding/json" ) // ProjectCreate struct for ProjectCreate type ProjectCreate struct { // The ID of the parent of the project. If specified on project creation, this places the project within a hierarchy and implicitly defines the owning domain, which will be the same domain as the parent specified. If `parent_id` is not specified and `is_domain` is `false`, then the project will use its owning domain as its parent. If `is_domain` is `true` (i.e. the project is acting as a domain), then `parent_id` must not specified (or if it is, it must be null) since domains have no parents. `parent_id` is immutable, and can’t be updated after the project is created - hence a project cannot be moved within the hierarchy. ParentId *string `json:"parent_id,omitempty"` // The new name of the project, which must be unique within the owning domain. A project can have the same name as its domain. Name string `json:"name"` // Indicates whether the project also acts as a domain. If set to `true`, this project acts as both a project and domain. As a domain, the project provides a name space in which you can create users, groups, and other projects. If set to `false`, this project behaves as a regular project that contains only resources. Default is `false`. You cannot update this parameter after you create the project. IsDomain *bool `json:"is_domain,omitempty"` // The new description of the project. Description *string `json:"description,omitempty"` // If set to true, project is enabled. If set to false, project is disabled. The default is true. Enabled *bool `json:"enabled,omitempty"` // The ID of the domain for the project. For projects acting as a domain, the domain_id must not be specified, it will be generated by the Identity service implementation. For regular projects (i.e. those not acing as a domain), if `domain_id` is not specified, but `parent_id` is specified, then the domain ID of the parent will be used. If neither `domain_id` or `parent_id` is specified, the Identity service implementation will default to the domain to which the client’s token is scoped. If both `domain_id` and `parent_id` are specified, and they do not indicate the same domain, an `Bad Request (400)` will be returned. DomainId *string `json:"domain_id,omitempty"` } // NewProjectCreate instantiates a new ProjectCreate object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed func NewProjectCreate(name string) *ProjectCreate { this := ProjectCreate{} this.Name = name return &this } // NewProjectCreateWithDefaults instantiates a new ProjectCreate object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set func NewProjectCreateWithDefaults() *ProjectCreate { this := ProjectCreate{} return &this } // GetParentId returns the ParentId field value if set, zero value otherwise. func (o *ProjectCreate) GetParentId() string { if o == nil || o.ParentId == nil { var ret string return ret } return *o.ParentId } // GetParentIdOk returns a tuple with the ParentId field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ProjectCreate) GetParentIdOk() (*string, bool) { if o == nil || o.ParentId == nil { return nil, false } return o.ParentId, true } // HasParentId returns a boolean if a field has been set. func (o *ProjectCreate) HasParentId() bool { if o != nil && o.ParentId != nil { return true } return false } // SetParentId gets a reference to the given string and assigns it to the ParentId field. func (o *ProjectCreate) SetParentId(v string) { o.ParentId = &v } // GetName returns the Name field value func (o *ProjectCreate) GetName() string { if o == nil { var ret string return ret } return o.Name } // GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *ProjectCreate) GetNameOk() (*string, bool) { if o == nil { return nil, false } return &o.Name, true } // SetName sets field value func (o *ProjectCreate) SetName(v string) { o.Name = v } // GetIsDomain returns the IsDomain field value if set, zero value otherwise. func (o *ProjectCreate) GetIsDomain() bool { if o == nil || o.IsDomain == nil { var ret bool return ret } return *o.IsDomain } // GetIsDomainOk returns a tuple with the IsDomain field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ProjectCreate) GetIsDomainOk() (*bool, bool) { if o == nil || o.IsDomain == nil { return nil, false } return o.IsDomain, true } // HasIsDomain returns a boolean if a field has been set. func (o *ProjectCreate) HasIsDomain() bool { if o != nil && o.IsDomain != nil { return true } return false } // SetIsDomain gets a reference to the given bool and assigns it to the IsDomain field. func (o *ProjectCreate) SetIsDomain(v bool) { o.IsDomain = &v } // GetDescription returns the Description field value if set, zero value otherwise. func (o *ProjectCreate) GetDescription() string { if o == nil || o.Description == nil { var ret string return ret } return *o.Description } // GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ProjectCreate) GetDescriptionOk() (*string, bool) { if o == nil || o.Description == nil { return nil, false } return o.Description, true } // HasDescription returns a boolean if a field has been set. func (o *ProjectCreate) HasDescription() bool { if o != nil && o.Description != nil { return true } return false } // SetDescription gets a reference to the given string and assigns it to the Description field. func (o *ProjectCreate) SetDescription(v string) { o.Description = &v } // GetEnabled returns the Enabled field value if set, zero value otherwise. func (o *ProjectCreate) GetEnabled() bool { if o == nil || o.Enabled == nil { var ret bool return ret } return *o.Enabled } // GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ProjectCreate) GetEnabledOk() (*bool, bool) { if o == nil || o.Enabled == nil { return nil, false } return o.Enabled, true } // HasEnabled returns a boolean if a field has been set. func (o *ProjectCreate) HasEnabled() bool { if o != nil && o.Enabled != nil { return true } return false } // SetEnabled gets a reference to the given bool and assigns it to the Enabled field. func (o *ProjectCreate) SetEnabled(v bool) { o.Enabled = &v } // GetDomainId returns the DomainId field value if set, zero value otherwise. func (o *ProjectCreate) GetDomainId() string { if o == nil || o.DomainId == nil { var ret string return ret } return *o.DomainId } // GetDomainIdOk returns a tuple with the DomainId field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *ProjectCreate) GetDomainIdOk() (*string, bool) { if o == nil || o.DomainId == nil { return nil, false } return o.DomainId, true } // HasDomainId returns a boolean if a field has been set. func (o *ProjectCreate) HasDomainId() bool { if o != nil && o.DomainId != nil { return true } return false } // SetDomainId gets a reference to the given string and assigns it to the DomainId field. func (o *ProjectCreate) SetDomainId(v string) { o.DomainId = &v } func (o ProjectCreate) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.ParentId != nil { toSerialize["parent_id"] = o.ParentId } if true { toSerialize["name"] = o.Name } if o.IsDomain != nil { toSerialize["is_domain"] = o.IsDomain } if o.Description != nil { toSerialize["description"] = o.Description } if o.Enabled != nil { toSerialize["enabled"] = o.Enabled } if o.DomainId != nil { toSerialize["domain_id"] = o.DomainId } return json.Marshal(toSerialize) } type NullableProjectCreate struct { value *ProjectCreate isSet bool } func (v NullableProjectCreate) Get() *ProjectCreate { return v.value } func (v *NullableProjectCreate) Set(val *ProjectCreate) { v.value = val v.isSet = true } func (v NullableProjectCreate) IsSet() bool { return v.isSet } func (v *NullableProjectCreate) Unset() { v.value = nil v.isSet = false } func NewNullableProjectCreate(val *ProjectCreate) *NullableProjectCreate { return &NullableProjectCreate{value: val, isSet: true} } func (v NullableProjectCreate) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableProjectCreate) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }
openapi/model_project_create.go
0.700383
0.491761
model_project_create.go
starcoder
package foundation // #include "affine_transform.h" import "C" import ( "unsafe" "github.com/hsiafan/cocoa/coregraphics" "github.com/hsiafan/cocoa/objc" ) type AffineTransform interface { objc.Object RotateByDegrees(angle coregraphics.Float) RotateByRadians(angle coregraphics.Float) ScaleBy(scale coregraphics.Float) ScaleXBy_YBy(scaleX coregraphics.Float, scaleY coregraphics.Float) TranslateXBy_YBy(deltaX coregraphics.Float, deltaY coregraphics.Float) AppendTransform(transform AffineTransform) PrependTransform(transform AffineTransform) Invert() TransformPoint(aPoint Point) Point TransformSize(aSize Size) Size TransformStruct() AffineTransformStruct SetTransformStruct(value AffineTransformStruct) } type NSAffineTransform struct { objc.NSObject } func MakeAffineTransform(ptr unsafe.Pointer) NSAffineTransform { return NSAffineTransform{ NSObject: objc.MakeObject(ptr), } } func (n NSAffineTransform) InitWithTransform(transform AffineTransform) NSAffineTransform { result_ := C.C_NSAffineTransform_InitWithTransform(n.Ptr(), objc.ExtractPtr(transform)) return MakeAffineTransform(result_) } func AllocAffineTransform() NSAffineTransform { result_ := C.C_NSAffineTransform_AllocAffineTransform() return MakeAffineTransform(result_) } func (n NSAffineTransform) Autorelease() NSAffineTransform { result_ := C.C_NSAffineTransform_Autorelease(n.Ptr()) return MakeAffineTransform(result_) } func (n NSAffineTransform) Retain() NSAffineTransform { result_ := C.C_NSAffineTransform_Retain(n.Ptr()) return MakeAffineTransform(result_) } func AffineTransform_Transform() NSAffineTransform { result_ := C.C_NSAffineTransform_AffineTransform_Transform() return MakeAffineTransform(result_) } func (n NSAffineTransform) RotateByDegrees(angle coregraphics.Float) { C.C_NSAffineTransform_RotateByDegrees(n.Ptr(), C.double(float64(angle))) } func (n NSAffineTransform) RotateByRadians(angle coregraphics.Float) { C.C_NSAffineTransform_RotateByRadians(n.Ptr(), C.double(float64(angle))) } func (n NSAffineTransform) ScaleBy(scale coregraphics.Float) { C.C_NSAffineTransform_ScaleBy(n.Ptr(), C.double(float64(scale))) } func (n NSAffineTransform) ScaleXBy_YBy(scaleX coregraphics.Float, scaleY coregraphics.Float) { C.C_NSAffineTransform_ScaleXBy_YBy(n.Ptr(), C.double(float64(scaleX)), C.double(float64(scaleY))) } func (n NSAffineTransform) TranslateXBy_YBy(deltaX coregraphics.Float, deltaY coregraphics.Float) { C.C_NSAffineTransform_TranslateXBy_YBy(n.Ptr(), C.double(float64(deltaX)), C.double(float64(deltaY))) } func (n NSAffineTransform) AppendTransform(transform AffineTransform) { C.C_NSAffineTransform_AppendTransform(n.Ptr(), objc.ExtractPtr(transform)) } func (n NSAffineTransform) PrependTransform(transform AffineTransform) { C.C_NSAffineTransform_PrependTransform(n.Ptr(), objc.ExtractPtr(transform)) } func (n NSAffineTransform) Invert() { C.C_NSAffineTransform_Invert(n.Ptr()) } func (n NSAffineTransform) TransformPoint(aPoint Point) Point { result_ := C.C_NSAffineTransform_TransformPoint(n.Ptr(), *(*C.CGPoint)(unsafe.Pointer(&aPoint))) return *((*coregraphics.Point)(unsafe.Pointer(&result_))) } func (n NSAffineTransform) TransformSize(aSize Size) Size { result_ := C.C_NSAffineTransform_TransformSize(n.Ptr(), *(*C.CGSize)(unsafe.Pointer(&aSize))) return *((*coregraphics.Size)(unsafe.Pointer(&result_))) } func (n NSAffineTransform) TransformStruct() AffineTransformStruct { result_ := C.C_NSAffineTransform_TransformStruct(n.Ptr()) return *((*AffineTransformStruct)(unsafe.Pointer(&result_))) } func (n NSAffineTransform) SetTransformStruct(value AffineTransformStruct) { C.C_NSAffineTransform_SetTransformStruct(n.Ptr(), *(*C.NSAffineTransformStruct)(unsafe.Pointer(&value))) }
foundation/affine_transform.go
0.659186
0.40645
affine_transform.go
starcoder
package aoc2020 /* --- Day 22: Crab Combat PART 2--- You lost to the small crab! Fortunately, crabs aren't very good at recursion. To defend your honor as a Raft Captain, you challenge the small crab to a game of Recursive Combat. Recursive Combat still starts by splitting the cards into two decks (you offer to play with the same starting decks as before - it's only fair). Then, the game consists of a series of rounds with a few changes: Before either player deals a card, if there was a previous round in this game that had exactly the same cards in the same order in the same players' decks, the game instantly ends in a win for player 1. Previous rounds from other games are not considered. (This prevents infinite games of Recursive Combat, which everyone agrees is a bad idea.) Otherwise, this round's cards must be in a new configuration; the players begin the round by each drawing the top card of their deck as normal. If both players have at least as many cards remaining in their deck as the value of the card they just drew, the winner of the round is determined by playing a new game of Recursive Combat (see below). Otherwise, at least one player must not have enough cards left in their deck to recurse; the winner of the round is the player with the higher-value card. As in regular Combat, the winner of the round (even if they won the round by winning a sub-game) takes the two cards dealt at the beginning of the round and places them on the bottom of their own deck (again so that the winner's card is above the other card). Note that the winner's card might be the lower-valued of the two cards if they won the round due to winning a sub-game. If collecting cards by winning the round causes a player to have all of the cards, they win, and the game ends. Here is an example of a small game that would loop forever without the infinite game prevention rule: Player 1: 43 19 Player 2: 2 29 14 During a round of Recursive Combat, if both players have at least as many cards in their own decks as the number on the card they just dealt, the winner of the round is determined by recursing into a sub-game of Recursive Combat. (For example, if player 1 draws the 3 card, and player 2 draws the 7 card, this would occur if player 1 has at least 3 cards left and player 2 has at least 7 cards left, not counting the 3 and 7 cards that were drawn.) To play a sub-game of Recursive Combat, each player creates a new deck by making a copy of the next cards in their deck (the quantity of cards copied is equal to the number on the card they drew to trigger the sub-game). During this sub-game, the game that triggered it is on hold and completely unaffected; no cards are removed from players' decks to form the sub-game. (For example, if player 1 drew the 3 card, their deck in the sub-game would be copies of the next three cards in their deck.) Here is a complete example of gameplay, where Game 1 is the primary game of Recursive Combat: === Game 1 === -- Round 1 (Game 1) -- Player 1's deck: 9, 2, 6, 3, 1 Player 2's deck: 5, 8, 4, 7, 10 Player 1 plays: 9 Player 2 plays: 5 Player 1 wins round 1 of game 1! -- Round 2 (Game 1) -- Player 1's deck: 2, 6, 3, 1, 9, 5 Player 2's deck: 8, 4, 7, 10 Player 1 plays: 2 Player 2 plays: 8 Player 2 wins round 2 of game 1! -- Round 3 (Game 1) -- Player 1's deck: 6, 3, 1, 9, 5 Player 2's deck: 4, 7, 10, 8, 2 Player 1 plays: 6 Player 2 plays: 4 Player 1 wins round 3 of game 1! -- Round 4 (Game 1) -- Player 1's deck: 3, 1, 9, 5, 6, 4 Player 2's deck: 7, 10, 8, 2 Player 1 plays: 3 Player 2 plays: 7 Player 2 wins round 4 of game 1! -- Round 5 (Game 1) -- Player 1's deck: 1, 9, 5, 6, 4 Player 2's deck: 10, 8, 2, 7, 3 Player 1 plays: 1 Player 2 plays: 10 Player 2 wins round 5 of game 1! -- Round 6 (Game 1) -- Player 1's deck: 9, 5, 6, 4 Player 2's deck: 8, 2, 7, 3, 10, 1 Player 1 plays: 9 Player 2 plays: 8 Player 1 wins round 6 of game 1! -- Round 7 (Game 1) -- Player 1's deck: 5, 6, 4, 9, 8 Player 2's deck: 2, 7, 3, 10, 1 Player 1 plays: 5 Player 2 plays: 2 Player 1 wins round 7 of game 1! -- Round 8 (Game 1) -- Player 1's deck: 6, 4, 9, 8, 5, 2 Player 2's deck: 7, 3, 10, 1 Player 1 plays: 6 Player 2 plays: 7 Player 2 wins round 8 of game 1! -- Round 9 (Game 1) -- Player 1's deck: 4, 9, 8, 5, 2 Player 2's deck: 3, 10, 1, 7, 6 Player 1 plays: 4 Player 2 plays: 3 Playing a sub-game to determine the winner... === Game 2 === -- Round 1 (Game 2) -- Player 1's deck: 9, 8, 5, 2 Player 2's deck: 10, 1, 7 Player 1 plays: 9 Player 2 plays: 10 Player 2 wins round 1 of game 2! -- Round 2 (Game 2) -- Player 1's deck: 8, 5, 2 Player 2's deck: 1, 7, 10, 9 Player 1 plays: 8 Player 2 plays: 1 Player 1 wins round 2 of game 2! -- Round 3 (Game 2) -- Player 1's deck: 5, 2, 8, 1 Player 2's deck: 7, 10, 9 Player 1 plays: 5 Player 2 plays: 7 Player 2 wins round 3 of game 2! -- Round 4 (Game 2) -- Player 1's deck: 2, 8, 1 Player 2's deck: 10, 9, 7, 5 Player 1 plays: 2 Player 2 plays: 10 Player 2 wins round 4 of game 2! -- Round 5 (Game 2) -- Player 1's deck: 8, 1 Player 2's deck: 9, 7, 5, 10, 2 Player 1 plays: 8 Player 2 plays: 9 Player 2 wins round 5 of game 2! -- Round 6 (Game 2) -- Player 1's deck: 1 Player 2's deck: 7, 5, 10, 2, 9, 8 Player 1 plays: 1 Player 2 plays: 7 Player 2 wins round 6 of game 2! The winner of game 2 is player 2! ...anyway, back to game 1. Player 2 wins round 9 of game 1! -- Round 10 (Game 1) -- Player 1's deck: 9, 8, 5, 2 Player 2's deck: 10, 1, 7, 6, 3, 4 Player 1 plays: 9 Player 2 plays: 10 Player 2 wins round 10 of game 1! -- Round 11 (Game 1) -- Player 1's deck: 8, 5, 2 Player 2's deck: 1, 7, 6, 3, 4, 10, 9 Player 1 plays: 8 Player 2 plays: 1 Player 1 wins round 11 of game 1! -- Round 12 (Game 1) -- Player 1's deck: 5, 2, 8, 1 Player 2's deck: 7, 6, 3, 4, 10, 9 Player 1 plays: 5 Player 2 plays: 7 Player 2 wins round 12 of game 1! -- Round 13 (Game 1) -- Player 1's deck: 2, 8, 1 Player 2's deck: 6, 3, 4, 10, 9, 7, 5 Player 1 plays: 2 Player 2 plays: 6 Playing a sub-game to determine the winner... === Game 3 === -- Round 1 (Game 3) -- Player 1's deck: 8, 1 Player 2's deck: 3, 4, 10, 9, 7, 5 Player 1 plays: 8 Player 2 plays: 3 Player 1 wins round 1 of game 3! -- Round 2 (Game 3) -- Player 1's deck: 1, 8, 3 Player 2's deck: 4, 10, 9, 7, 5 Player 1 plays: 1 Player 2 plays: 4 Playing a sub-game to determine the winner... === Game 4 === -- Round 1 (Game 4) -- Player 1's deck: 8 Player 2's deck: 10, 9, 7, 5 Player 1 plays: 8 Player 2 plays: 10 Player 2 wins round 1 of game 4! The winner of game 4 is player 2! ...anyway, back to game 3. Player 2 wins round 2 of game 3! -- Round 3 (Game 3) -- Player 1's deck: 8, 3 Player 2's deck: 10, 9, 7, 5, 4, 1 Player 1 plays: 8 Player 2 plays: 10 Player 2 wins round 3 of game 3! -- Round 4 (Game 3) -- Player 1's deck: 3 Player 2's deck: 9, 7, 5, 4, 1, 10, 8 Player 1 plays: 3 Player 2 plays: 9 Player 2 wins round 4 of game 3! The winner of game 3 is player 2! ...anyway, back to game 1. Player 2 wins round 13 of game 1! -- Round 14 (Game 1) -- Player 1's deck: 8, 1 Player 2's deck: 3, 4, 10, 9, 7, 5, 6, 2 Player 1 plays: 8 Player 2 plays: 3 Player 1 wins round 14 of game 1! -- Round 15 (Game 1) -- Player 1's deck: 1, 8, 3 Player 2's deck: 4, 10, 9, 7, 5, 6, 2 Player 1 plays: 1 Player 2 plays: 4 Playing a sub-game to determine the winner... === Game 5 === -- Round 1 (Game 5) -- Player 1's deck: 8 Player 2's deck: 10, 9, 7, 5 Player 1 plays: 8 Player 2 plays: 10 Player 2 wins round 1 of game 5! The winner of game 5 is player 2! ...anyway, back to game 1. Player 2 wins round 15 of game 1! -- Round 16 (Game 1) -- Player 1's deck: 8, 3 Player 2's deck: 10, 9, 7, 5, 6, 2, 4, 1 Player 1 plays: 8 Player 2 plays: 10 Player 2 wins round 16 of game 1! -- Round 17 (Game 1) -- Player 1's deck: 3 Player 2's deck: 9, 7, 5, 6, 2, 4, 1, 10, 8 Player 1 plays: 3 Player 2 plays: 9 Player 2 wins round 17 of game 1! The winner of game 1 is player 2! == Post-game results == Player 1's deck: Player 2's deck: 7, 5, 6, 2, 4, 1, 10, 8, 9, 3 After the game, the winning player's score is calculated from the cards they have in their original deck using the same rules as regular Combat. In the above game, the winning player's score is 291. Defend your honor as Raft Captain by playing the small crab in a game of Recursive Combat using the same two decks as before. What is the winning player's score? */ import ( "fmt" goutils "github.com/simonski/goutils" ) func AOC_2020_22_part2_attempt1(cli *goutils.CLI) { } func (c *Combat) PlayDay2() { winnerIsP1 := PlayRecursive(c.Player1, c.Player2, 0) if winnerIsP1 { fmt.Printf("P1 is recursive winner, score is %v\n", c.Player1.GetScore()) } else { fmt.Printf("P2 is recursive winner, score is %v.\n", c.Player2.GetScore()) } } func PlayRecursive(player1 *Player, player2 *Player, gameNumber int) bool { fmt.Printf("PlayRecusive [%v]\n", gameNumber) fmt.Printf("PlayRecusive [%v] P1 %v\n", gameNumber, player1.Cards) fmt.Printf("PlayRecusive [%v] P2 %v\n", gameNumber, player2.Cards) gameNumber++ round := 0 hands := make(map[string]bool) for { // Before either player deals a card, if there was a previous round in this game that had exactly the same cards in the same order in the same players' decks, the game instantly ends in a win for player 1. Previous rounds from other games are not considered. (This prevents infinite games of Recursive Combat, which everyone agrees is a bad idea.) p1Winner := false hand := NewGameHand(player1, player2) _, exists := hands[hand] if exists { p1Winner = true return true } else { hands[hand] = true } p1 := player1.Draw() p2 := player2.Draw() if len(player1.Cards) >= p1 && len(player2.Cards) >= p2 { // TRUE: If both players have at least as many cards remaining in their deck as the value of the card they just drew, the winner of the round is determined by playing a new game of Recursive Combat (see below). p1Winner = PlayRecursive(player1.Copy(p1), player2.Copy(p2), gameNumber) } else if p1 > p2 { // P1 is winner p1Winner = true } else { // P2 is winner p1Winner = false } if p1Winner { player1.AddCard(p1) player1.AddCard(p2) } else { // P2 is winner player2.AddCard(p2) player2.AddCard(p1) } round++ if player1.Size() == 0 { fmt.Printf("PlayRecusive [%v] P2 is winner %v\n", gameNumber, player2.Cards) return false } else if player2.Size() == 0 { fmt.Printf("PlayRecusive [%v] P1 is winner %v\n", gameNumber, player1.Cards) return true } } } func NewGameHand(player1 *Player, player2 *Player) string { line := "P1," for _, card := range player1.Cards { line += fmt.Sprintf("%v,", card) } line += "P2," for _, card := range player2.Cards { line += fmt.Sprintf("%v,", card) } return line } // Copy is a simple copy constructor with one caveat, it only copies the //nuuber of cards specified func (player *Player) Copy(numberOfCardsToCopy int) *Player { p := Player{} cards := make([]int, 0) for index, card := range player.Cards { if index < numberOfCardsToCopy { cards = append(cards, card) } else { break } } p.Cards = cards return &p }
app/aoc2020/aoc2020_22_part2.go
0.709019
0.813794
aoc2020_22_part2.go
starcoder
package reporting import ( "fmt" "io" "os" "sort" "time" "github.com/jinzhu/now" "github.com/markosamuli/glassfactory/model" "github.com/markosamuli/glassfactory/pkg/dateutil" "github.com/olekukonko/tablewriter" ) // FiscalYear represents a time range for a fiscal year type FiscalYear struct { Start time.Time End time.Time } // String returns the fiscal year in FY YYYY format. func (fy FiscalYear) String() string { return fmt.Sprintf("FY %04d", fy.End.Year()) } // Before reports whether fy occurs before fy2. func (fy FiscalYear) Before(fy2 FiscalYear) bool { return fy.End.Before(fy2.End) } // After reports whether fy occurs after fy2. func (fy FiscalYear) After(fy2 FiscalYear) bool { return fy2.Before(fy) } // NewFiscalYear returns new FiscalYear for the given date ending at the given month func NewFiscalYear(d time.Time, finalMonth time.Month) *FiscalYear { var start time.Time var end time.Time if finalMonth < time.December { start = time.Date(d.Year()-1, finalMonth+1, 1, 0, 0, 0, 0, time.Local) end = now.With(time.Date(d.Year(), finalMonth, 1, 23, 59, 59, 999999999, time.Local)).EndOfMonth() } else { start = time.Date(d.Year(), time.January, 1, 0, 0, 0, 0, time.Local) end = now.With(time.Date(d.Year(), time.December, 1, 23, 59, 59, 999999999, time.Local)).EndOfMonth() } if d.Before(start) { start = start.AddDate(-1, 0, 0) end = end.AddDate(-1, 0, 0) } else if d.After(end) { start = start.AddDate(1, 0, 0) end = end.AddDate(1, 0, 0) } return &FiscalYear{ Start: start, End: end, } } // FiscalYearMemberTimeReports convers MemberTimeReport data into FiscalYearMemberTimeReport func FiscalYearMemberTimeReports(reports []*model.MemberTimeReport, finalMonth time.Month) []*FiscalYearMemberTimeReport { periods := make(map[FiscalYear]*FiscalYearMemberTimeReport, 0) for _, r := range reports { fy := *NewFiscalYear(r.Date.In(time.Local), finalMonth) p, ok := periods[fy] if !ok { p = NewFiscalYearMemberTimeReport(r.UserID, fy) periods[fy] = p } p.Append(r) } fyr := make([]*FiscalYearMemberTimeReport, 0, len(periods)) for _, p := range periods { fyr = append(fyr, p) } sort.Sort(ByFiscalYear(fyr)) return fyr } // ByFiscalYear implements sort.Interface based on the FiscalYear field. type ByFiscalYear []*FiscalYearMemberTimeReport func (a ByFiscalYear) Len() int { return len(a) } func (a ByFiscalYear) Less(i, j int) bool { return a[i].FiscalYear.Before(a[j].FiscalYear) } func (a ByFiscalYear) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // FiscalYearMemberTimeReport represents MemberTimeReport data for a given fiscal year type FiscalYearMemberTimeReport struct { UserID int FiscalYear FiscalYear Start dateutil.Date End dateutil.Date Reports []*model.MemberTimeReport } // NewFiscalYearMemberTimeReport creates FiscalYearMemberTimeReport for a user and given fiscal year func NewFiscalYearMemberTimeReport(userID int, fy FiscalYear) *FiscalYearMemberTimeReport { return &FiscalYearMemberTimeReport{ UserID: userID, FiscalYear: fy, Reports: make([]*model.MemberTimeReport, 0), } } // RenderTable displays FiscalYearMemberTimeReport in using NewFiscalYearTimeReportTableWriter func (tr *FiscalYearMemberTimeReport) RenderTable(writer io.Writer) { reportGroups := make(map[string][]*FiscalYearTimeReport) projectReports := ProjectMemberTimeReports(tr.Reports) for _, pr := range projectReports { r := &FiscalYearTimeReport{ FiscalYear: tr.FiscalYear, Client: pr.Client, Project: pr.Project, Planned: pr.Planned(), Actual: pr.Actual(), } billableStatus := r.BillableStatus() br, ok := reportGroups[billableStatus] if !ok { br = make([]*FiscalYearTimeReport, 0) } br = append(br, r) reportGroups[billableStatus] = br } table := NewFiscalYearTimeReportTableWriter(writer) for _, r := range reportGroups { sort.SliceStable(r, func(i, j int) bool { if r[i].Client.ID != r[j].Client.ID { return r[i].Client.ID < r[i].Client.ID } if r[i].Client.OfficeID != r[j].Client.OfficeID { return r[i].Client.OfficeID < r[i].Client.OfficeID } if r[i].Project.ID != r[j].Project.ID { return r[i].Project.ID < r[i].Project.ID } return true }) for _, tr := range r { table.Append(tr) } } table.Render() } // Append a MemberTimeReport to the FiscalYearMemberTimeReport func (tr *FiscalYearMemberTimeReport) Append(r *model.MemberTimeReport) { if !tr.Start.IsValid() || r.Date.Before(tr.Start) { tr.Start = r.Date } if !tr.End.IsValid() || r.Date.Before(tr.End) { tr.End = r.Date } tr.Reports = append(tr.Reports, r) } // Planned returns total planned hours func (tr *FiscalYearMemberTimeReport) Planned() float64 { var planned float64 for _, r := range tr.Reports { planned += r.Planned } return planned } // Actual returns total actual hours func (tr *FiscalYearMemberTimeReport) Actual() float64 { var actual float64 for _, r := range tr.Reports { actual += r.Actual } return actual } // FiscalYearTimeReport represents fiscal year totals for a given client and project type FiscalYearTimeReport struct { FiscalYear FiscalYear Client *model.Client Project *model.Project Planned float64 Actual float64 } // BillableStatus returns project's billable status func (r *FiscalYearTimeReport) BillableStatus() string { return FormatBillableStatus(r.Project.BillableStatus) } // FiscalYearTimeReportTableWriter is used for displaying reports in table format type FiscalYearTimeReportTableWriter struct { table *tablewriter.Table totals map[string]*TimeReportTotals } // NewFiscalYearTimeReportTableWriter creates a new FiscalYearTimeReportTableWriter func NewFiscalYearTimeReportTableWriter(writer io.Writer) *FiscalYearTimeReportTableWriter { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{ "Fiscal Year", "Billable", "Client", "Project", "Actual", "Planned", "Diff", }) table.SetAutoMergeCells(false) table.SetRowLine(true) return &FiscalYearTimeReportTableWriter{ table: table, totals: make(map[string]*TimeReportTotals), } } // Append adds FiscalYearTimeReport data to the table and updates the total hours func (t *FiscalYearTimeReportTableWriter) Append(r *FiscalYearTimeReport) { billable := r.BillableStatus() t.table.Append([]string{ fmt.Sprintf("%s", r.FiscalYear), billable, r.Client.Name, r.Project.Name, fmt.Sprintf("%6.2f ", r.Actual), fmt.Sprintf("%6.2f ", r.Planned), fmt.Sprintf("%6.2f ", r.Actual-r.Planned), }) totals, ok := t.totals[billable] if !ok { totals = &TimeReportTotals{planned: 0.0, actual: 0.0} } totals.planned += r.Planned totals.actual += r.Actual t.totals[billable] = totals } // Render displays the report data in a table format func (t *FiscalYearTimeReportTableWriter) Render() { var planned float64 var actual float64 for billable, totals := range t.totals { totalHeader := fmt.Sprintf("Total %s", billable) t.table.Append([]string{ "", "", "", totalHeader, fmt.Sprintf("%6.2f ", totals.actual), fmt.Sprintf("%6.2f ", totals.planned), fmt.Sprintf("%6.2f ", totals.actual-totals.planned), }) planned += totals.planned actual += totals.actual } t.table.SetFooter([]string{ "", "", "", "Total", fmt.Sprintf("%6.2f ", actual), fmt.Sprintf("%6.2f ", planned), fmt.Sprintf("%6.2f ", actual-planned), }) t.table.Render() }
reporting/fiscal_year.go
0.638046
0.467028
fiscal_year.go
starcoder
package crosslink import ( "math" "unsafe" ) // RangeTriggerNode is a node that belongs to a RangeTrigger // each RangeTrigger has 2 RangeTriggerNode, one positive and one negative, represents 2 sides of a range // it implements CLPosImp as CLNode does type RangeTriggerNode struct { CLNode rangeX CLPosValType rangeZ CLPosValType oldRangeX CLPosValType oldRangeZ CLPosValType myTrigger *RangeTrigger isPositive bool } var g_offsetRangeTriggerNode uintptr func initOffsetRangeTriggerNode() { dummy := (*RangeTriggerNode)(unsafe.Pointer(&g_offsetRangeTriggerNode)) g_offsetRangeTriggerNode = uintptr(unsafe.Pointer(&dummy.CLNode)) - uintptr(unsafe.Pointer(dummy)) } // RangeTrigger is a representation of a trigger range type RangeTrigger struct { ownerEntNode *EntityListNode upperBound *RangeTriggerNode lowerBound *RangeTriggerNode posX CLPosValType posZ CLPosValType oldX CLPosValType oldZ CLPosValType rangeID RangeIDValType eventTp EventValType } // newRangeTriggerNode creates a new RangeTriggerNode // isPositive means is upper bound, or the position value is bigger // the given parameters rangeX, rangeZ should be greater than 0 func newRangeTriggerNode(rTrigger *RangeTrigger, isPositive bool, rangeX CLPosValType, rangeZ CLPosValType) *RangeTriggerNode { var node = new(RangeTriggerNode) node.isPositive = isPositive node.myTrigger = rTrigger if isPositive { node.rangeX = rangeX node.rangeZ = rangeZ } else { node.rangeX = -rangeX node.rangeZ = -rangeZ } node.nodeType = CLNODE_TRIGGER // now it's not in a proper cross linked list return node } func (thisNode *RangeTriggerNode) initialShuffle(oldX CLPosValType, oldZ CLPosValType) { // don't trigger anything thisNode.oldRangeX = 0 thisNode.oldRangeZ = 0 shuffleXThenZ(thisNode, oldX, oldZ) thisNode.oldRangeX = thisNode.rangeX thisNode.oldRangeZ = thisNode.rangeZ } func (thisNode *RangeTriggerNode) x() CLPosValType { return thisNode.myTrigger.x() + thisNode.rangeX } func (thisNode *RangeTriggerNode) z() CLPosValType { return thisNode.myTrigger.z() + thisNode.rangeZ } func (thisNode *RangeTriggerNode) getEntityID() EntityIDValType { return thisNode.myTrigger.ownerEntNode.aoiNode.entID } // this 2 methods overrides the methods of 'parent' CLNode func (thisNode *RangeTriggerNode) crossedX(otherNode CLNodeImp, positiveCross bool, otherOldX CLPosValType, otherOldZ CLPosValType) { if thisNode.getEntityID() == otherNode.getEntityID() { return } wasInZRange := thisNode.myTrigger.wasInZRange(otherOldZ, Abs(thisNode.oldRangeZ)) if !wasInZRange { return } isEnter := bool(thisNode.isPositive != positiveCross) if isEnter { if thisNode.myTrigger.isInXRange(otherNode.x(), Abs(thisNode.rangeX)) && thisNode.myTrigger.isInZRange(otherNode.z(), Abs(thisNode.rangeZ)) { thisNode.myTrigger.triggerEnter(otherNode) } } else { if thisNode.myTrigger.wasInXRange(otherOldX, Abs(thisNode.oldRangeX)) { thisNode.myTrigger.triggerLeave(otherNode) } } } func (thisNode *RangeTriggerNode) crossedZ(otherNode CLNodeImp, positiveCross bool, otherOldX CLPosValType, otherOldZ CLPosValType) { if thisNode.getEntityID() == otherNode.getEntityID() { return } wasInXRange := thisNode.myTrigger.wasInXRange(otherOldX, Abs(thisNode.oldRangeX)) if !wasInXRange { return } isEnter := bool(thisNode.isPositive != positiveCross) if isEnter { if thisNode.myTrigger.isInZRange(otherNode.z(), Abs(thisNode.rangeZ)) { thisNode.myTrigger.triggerEnter(otherNode) } } else { if thisNode.myTrigger.wasInXRange(otherOldX, Abs(thisNode.oldRangeX)) && thisNode.myTrigger.wasInZRange(otherOldZ, Abs(thisNode.oldRangeZ)) { thisNode.myTrigger.triggerLeave(otherNode) } } } func (thisNode *RangeTriggerNode) setRange(rangeX CLPosValType, rangeZ CLPosValType) { oldX, oldZ := thisNode.x(), thisNode.z() thisNode.rangeX, thisNode.rangeZ = rangeX, rangeZ shuffleXThenZ(thisNode, oldX, oldZ) thisNode.oldRangeX, thisNode.oldRangeZ = thisNode.rangeX, thisNode.rangeZ } // newRangeTrigger is a method for creating new RangeTrigger func newRangeTrigger(ownerNode *EntityListNode, rangeX CLPosValType, rangeZ CLPosValType, rangeID RangeIDValType, eventTp EventValType) *RangeTrigger { var trigger = new(RangeTrigger) trigger.ownerEntNode = ownerNode trigger.upperBound = newRangeTriggerNode(trigger, true, rangeX, rangeZ) trigger.lowerBound = newRangeTriggerNode(trigger, false, rangeX, rangeZ) trigger.posX, trigger.posZ = ownerNode.x(), ownerNode.z() trigger.oldX, trigger.oldZ = trigger.posX, trigger.posZ trigger.rangeID = rangeID trigger.eventTp = eventTp return trigger } func (thisTrigger *RangeTrigger) x() CLPosValType { return thisTrigger.posX } func (thisTrigger *RangeTrigger) z() CLPosValType { return thisTrigger.posZ } func (thisTrigger *RangeTrigger) owner() CLNodeImp { return thisTrigger.ownerEntNode } func (thisTrigger *RangeTrigger) isInXRange(x CLPosValType, rangeX CLPosValType) bool { return (thisTrigger.posX-rangeX) < x && x <= (thisTrigger.posX+rangeX) } func (thisTrigger *RangeTrigger) isInZRange(z CLPosValType, rangeZ CLPosValType) bool { return (thisTrigger.posZ-rangeZ) < z && z <= (thisTrigger.posZ+rangeZ) } func (thisTrigger *RangeTrigger) wasInXRange(x CLPosValType, rangeX CLPosValType) bool { return (thisTrigger.oldX-rangeX) < x && x <= (thisTrigger.oldX+rangeX) } func (thisTrigger *RangeTrigger) wasInZRange(z CLPosValType, rangeZ CLPosValType) bool { return (thisTrigger.oldZ-rangeZ) < z && z <= (thisTrigger.oldZ+rangeZ) } func (thisTrigger *RangeTrigger) triggerEnter(entering CLNodeImp) { thisTrigger.ownerEntNode.aoiNode.onEntityEnterRange(entering.getEntityID(), thisTrigger.rangeID) } func (thisTrigger *RangeTrigger) triggerLeave(leaving CLNodeImp) { thisTrigger.ownerEntNode.aoiNode.onEntityLeaveRange(leaving.getEntityID(), thisTrigger.rangeID) } func (thisTrigger *RangeTrigger) setRange(rangeX CLPosValType, rangeZ CLPosValType) { rangeX = Max(rangeX, 0.00000001) rangeZ = Max(rangeZ, 0.00000001) thisTrigger.upperBound.setRange(rangeX, rangeZ) thisTrigger.lowerBound.setRange(rangeX, rangeZ) } func (thisTrigger *RangeTrigger) insert() { cursor := thisTrigger.ownerEntNode.pNextX cursor.getCLNodePtr().insertBeforeX(&thisTrigger.lowerBound.CLNode) cursor.getCLNodePtr().insertBeforeX(&thisTrigger.upperBound.CLNode) cursor = thisTrigger.ownerEntNode.pNextZ cursor.getCLNodePtr().insertBeforeZ(&thisTrigger.lowerBound.CLNode) cursor.getCLNodePtr().insertBeforeZ(&thisTrigger.upperBound.CLNode) thisTrigger.upperBound.initialShuffle(thisTrigger.upperBound.x(), thisTrigger.upperBound.z()) thisTrigger.lowerBound.initialShuffle(thisTrigger.lowerBound.x(), thisTrigger.lowerBound.z()) } func (thisTrigger *RangeTrigger) removeMyself() { thisTrigger.posZ = math.MaxFloat32 thisTrigger.shuffleZ() thisTrigger.upperBound.removeFromRangeList() thisTrigger.lowerBound.removeFromRangeList() } func (thisTrigger *RangeTrigger) moveCenterToPos(tgtX CLPosValType, tgtZ CLPosValType) { thisTrigger.posX, thisTrigger.posZ = tgtX, tgtZ thisTrigger.shuffleXThenZ() } func (thisTrigger *RangeTrigger) shuffleZ() { shuffleZ(thisTrigger.upperBound, thisTrigger.oldX+thisTrigger.upperBound.rangeX, thisTrigger.oldZ+thisTrigger.upperBound.rangeZ) shuffleZ(thisTrigger.lowerBound, thisTrigger.oldX+thisTrigger.lowerBound.rangeX, thisTrigger.oldZ+thisTrigger.lowerBound.rangeZ) thisTrigger.oldZ = thisTrigger.posZ } func (thisTrigger *RangeTrigger) shuffleXThenZ() { upOldX := thisTrigger.oldX + thisTrigger.upperBound.rangeX upOldZ := thisTrigger.oldZ + thisTrigger.upperBound.rangeZ loOldX := thisTrigger.oldX + thisTrigger.lowerBound.rangeX loOldZ := thisTrigger.oldZ + thisTrigger.lowerBound.rangeZ // let the range expand first then shrink if thisTrigger.oldX < thisTrigger.posX { shuffleX(thisTrigger.upperBound, upOldX, upOldZ) shuffleX(thisTrigger.lowerBound, loOldX, loOldZ) } else { shuffleX(thisTrigger.lowerBound, loOldX, loOldZ) shuffleX(thisTrigger.upperBound, upOldX, upOldZ) } if thisTrigger.oldZ < thisTrigger.posZ { shuffleZ(thisTrigger.upperBound, upOldX, upOldZ) shuffleZ(thisTrigger.lowerBound, loOldX, upOldZ) } else { shuffleZ(thisTrigger.lowerBound, loOldX, upOldZ) shuffleZ(thisTrigger.upperBound, upOldX, upOldZ) } thisTrigger.oldX, thisTrigger.oldZ = thisTrigger.posX, thisTrigger.posZ }
aoi/aoi_cross_link/range_trigger.go
0.72487
0.505737
range_trigger.go
starcoder
// Package xor implements a nearest-neighbor data structure for the XOR-metric package xor import ( "errors" "fmt" "strconv" "unsafe" ) // Key represents a point in the XOR-space type Key uint64 // Key implements interface Item func (id Key) Key() Key { return id } // Bit returns the k-th MSB. k ranges from 0 to 63 inclusive. func (id Key) Bit(k int) int { return int((id >> uint(k)) & 1) } // String returns a textual representation of the id func (id Key) String() string { return fmt.Sprintf("%064b", id) } // String returns a textual representation of the id, truncated to the k MSBs. func (id Key) ShortString(k uint) string { shift := uint(8*unsafe.Sizeof(id)) - k return fmt.Sprintf("%0"+strconv.Itoa(int(k))+"b", ((id << shift) >> shift)) } // Item is any type that has an XOR-space Key type Item interface { Key() Key } // Metric is an XOR-metric space that supports point addition and nearest neighbor (NN) queries. // The zero value is an empty metric space. type Metric struct { Item sub [2]*Metric n int // Number of items (not nodes) in the subtree of and including this node } var ErrDup = errors.New("duplicate point") // Iterate calls f on each node of the XOR-tree. func (m *Metric) Iterate(f func(Item)) { f(m.Item) if m.sub[0] != nil { m.sub[0].Iterate(f) } if m.sub[1] != nil { m.sub[1].Iterate(f) } } // Copy returns a deep copy of the metric func (m *Metric) Copy() *Metric { m_ := &Metric{ Item: m.Item, n: m.n, } if m.sub[0] != nil { m_.sub[0] = m.sub[0].Copy() } if m.sub[1] != nil { m_.sub[1] = m.sub[1].Copy() } return m_ } // Clear removes all points from the metric func (m *Metric) Clear() { *m = Metric{} } // Size returns the number of points in the metric func (m *Metric) Size() int { return m.n } func (m *Metric) calcSize() { m.n = 0 if m.sub[0] != nil { m.n += m.sub[0].n } if m.sub[1] != nil { m.n += m.sub[1].n } if m.Item != nil { m.n++ } } // Add adds the item to the metric. It returns the smallest number of // significant bits that distinguish this item from the rest in the metric. func (m *Metric) Add(item Item) (level int, err error) { return m.add(item, 0) } func (m *Metric) add(item Item, r int) (bottom int, err error) { defer m.calcSize() if m.Item == nil { if m.sub[0] == nil && m.sub[1] == nil { // This is an empty leaf node m.Item = item return r, nil } // This is an intermediate node return m.forward(item, r) } // This is a non-empty leaf node if m.Item.Key() == item.Key() { return r, ErrDup } if _, err = m.forward(m.Item, r); err != nil { panic("¢") } m.Item = nil bottom, err = m.forward(item, r) if err != nil { panic("¢") } return bottom, err } func (m *Metric) forward(item Item, r int) (bottom int, err error) { j := item.Key().Bit(r) if m.sub[j] == nil { m.sub[j] = &Metric{} } return m.sub[j].add(item, r+1) } // Remove removes an item with id from the metric, if present. // It returns the removed item, or nil if non present. func (m *Metric) Remove(id Key) Item { item, _ := m.remove(id, 0) return item } func (m *Metric) remove(id Key, r int) (Item, bool) { defer m.calcSize() if m.Item != nil { if m.Item.Key() == id { item := m.Item m.Item = nil return item, true } return nil, false } b := id.Bit(r) sub := m.sub[b] if sub == nil { return nil, false } item, emptied := sub.remove(id, r+1) if emptied { m.sub[b] = nil if m.sub[1-b] == nil { return item, true } } return item, false } // Nearest returns the k points in the metric that are closest to the pivot. func (m *Metric) Nearest(pivot Key, k int) []Item { return m.nearest(pivot, k, 0) } func (m *Metric) nearest(pivot Key, k int, r int) []Item { if k == 0 { return nil } if m.Item != nil { return []Item{m.Item} } var result []Item b := pivot.Bit(r) sub := m.sub[b] if sub != nil { result = sub.nearest(pivot, k, r+1) } k -= len(result) sub = m.sub[1-b] if sub != nil { result = append(result, sub.nearest(pivot, k, r+1)...) } return result }
src/circuit/kit/xor/xor.go
0.852537
0.421373
xor.go
starcoder
package indicator import ( "sync" "time" "github.com/evsamsonov/trading-timeseries/timeseries" ) const oneDay = time.Hour * 24 // VolumeWeightedAveragePrice represents indicator to calculate volume-weighted average price (VWAP). // More details https://en.wikipedia.org/wiki/Volume-weighted_average_price type VolumeWeightedAveragePrice struct { series *timeseries.TimeSeries cache *vwapCache } // NewVolumeWeightedAveragePrice creates VolumeWeightedAveragePrice func NewVolumeWeightedAveragePrice(series *timeseries.TimeSeries) *VolumeWeightedAveragePrice { return &VolumeWeightedAveragePrice{ series: series, cache: newVwapCache(), } } // Calculate returns VWAP value for candle with given index func (v *VolumeWeightedAveragePrice) Calculate(index int) float64 { unit, ok := v.cache.get(index) if ok { return unit.vwap } day := v.series.Candle(index).Time.Truncate(oneDay) startIndex, unit := v.findLastCalculated(index, day) volumeTotal := unit.volumeTotal priceVolumeTotal := unit.priceVolumeTotal for i := startIndex; i <= index; i++ { candle := v.series.Candle(i) if !candle.Time.Truncate(oneDay).Equal(day) { break } typicalPrice := calcTypicalPrice(candle) priceVolumeTotal += float64(candle.Volume) * typicalPrice volumeTotal += candle.Volume v.cache.add(i, vwapUnit{ vwap: priceVolumeTotal / float64(volumeTotal), priceVolumeTotal: priceVolumeTotal, volumeTotal: volumeTotal, }) } unit, _ = v.cache.get(index) return unit.vwap } func (v *VolumeWeightedAveragePrice) findLastCalculated(index int, day time.Time) (startIndex int, item vwapUnit) { for i := index - 1; i >= 0; i-- { candle := v.series.Candle(i) if !candle.Time.Truncate(oneDay).Equal(day) { return i + 1, vwapUnit{} } item, ok := v.cache.get(i) if ok { return i + 1, item } } return 0, vwapUnit{} } func calcTypicalPrice(candle *timeseries.Candle) float64 { return (candle.High + candle.Low + candle.Close) / 3 } type vwapCache struct { mu sync.RWMutex items map[int]vwapUnit } func newVwapCache() *vwapCache { return &vwapCache{ items: make(map[int]vwapUnit), } } type vwapUnit struct { vwap float64 priceVolumeTotal float64 volumeTotal int64 } func (v *vwapCache) get(index int) (vwapUnit, bool) { v.mu.RLock() defer v.mu.RUnlock() val, ok := v.items[index] return val, ok } func (v *vwapCache) add(index int, item vwapUnit) { v.mu.Lock() defer v.mu.Unlock() v.items[index] = item }
indicator/volume_weighted_average_price.go
0.777046
0.4231
volume_weighted_average_price.go
starcoder
package DG2D import ( "fmt" "math" "github.com/notargets/gocfd/DG1D" "github.com/notargets/gocfd/utils" ) type RTBasis2DSimplex struct { P int // Polynomial Order Np int // Number of terms and nodes in basis NpInt, NpEdge int // Number of nodes in interior and on each edge, Np = 2*NpInt + 3*NpEdge R, S utils.Vector // Node locations within [-1,1] reference triangle Scalar2DBasis Basis2D // Basis used for part of the RT basis construction V [2]utils.Matrix Div, DivInt utils.Matrix } /* This is a second Raviart-Thomas element basis implementation within this project. This implementation is based on the paper "Computational Bases for RTk and BDMk on Triangles" by <NAME> In this approach, edges are specifically addressed with 1D Lagrange polynomials multiplied by edge specific basis functions, while the interior points are composed of a supplied 2D scalar polynomial multiplied by a barycentric basis for the triangle. */ func NewRTBasis2DSimplex(P int, useLagrangeBasis bool) (rtb *RTBasis2DSimplex) { var Rint, Sint utils.Vector rtb = &RTBasis2DSimplex{ P: P, Np: (P + 1) * (P + 3), NpInt: P * (P + 1) / 2, // Number of interior points is same as the 2D scalar space one order lesser NpEdge: P + 1, // Each edge is P+1 nodes } if P > 0 { if P < 9 { Rint, Sint = NodesEpsilon(P - 1) } else { Rint, Sint = XYtoRS(Nodes2D(P - 1)) } if useLagrangeBasis { rtb.Scalar2DBasis = NewLagrangeBasis2D(P-1, Rint, Sint) // Basis used as part of non-Normal basis elements } else { rtb.Scalar2DBasis = NewJacobiBasis2D(P-1, Rint, Sint) // Basis used as part of non-Normal basis elements } } rtb.R, rtb.S = rtb.ExtendGeomToRT(Rint, Sint) rtb.CalculateBasis() return } func (rtb *RTBasis2DSimplex) getLocationType(i int) (locationType RTPointType) { var ( NpInt = rtb.NpInt NpEdge = rtb.NpEdge ) switch { case i < NpInt: // Unit vector is [1,0] locationType = InteriorR case i >= NpInt && i < 2*NpInt: // Unit vector is [0,1] locationType = InteriorS case i >= 2*NpInt && i < 2*NpInt+NpEdge: // Edge1: Unit vector is [0,-1] locationType = Edge1 case i >= 2*NpInt+NpEdge && i < 2*NpInt+2*NpEdge: // Edge2: Unit vector is [1/sqrt(2), 1/sqrt(2)] locationType = Edge2 case i >= 2*NpInt+2*NpEdge && i < 2*NpInt+3*NpEdge: // Edge3: Unit vector is [-1,0] locationType = Edge3 default: fmt.Errorf("unable to match node location for node %d and Np = %d", i, rtb.Np) } return } func (rtb *RTBasis2DSimplex) EvaluateBasisAtLocation(r, s float64, derivO ...DerivativeDirection) (p0, p1 []float64) { var ( deriv DerivativeDirection RGauss = DG1D.LegendreZeros(rtb.P) ) if len(derivO) != 0 { deriv = derivO[0] } else { deriv = None } Basis2DTerm := func(r, s float64, i, j int, dv DerivativeDirection) (p float64) { switch dv { case None: p = rtb.Scalar2DBasis.PolynomialTerm(r, s, i, j) case Dr: p = rtb.Scalar2DBasis.PolynomialTermDr(r, s, i, j) case Ds: p = rtb.Scalar2DBasis.PolynomialTermDs(r, s, i, j) } return } e1rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p, _ = rtb.getCoreBasisTerm(e1, r, s, deriv) return } e1sf := func(r, s float64, deriv DerivativeDirection) (p float64) { _, p = rtb.getCoreBasisTerm(e1, r, s, deriv) return } e2rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p, _ = rtb.getCoreBasisTerm(e2, r, s, deriv) return } e2sf := func(r, s float64, deriv DerivativeDirection) (p float64) { _, p = rtb.getCoreBasisTerm(e2, r, s, deriv) return } e3rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p, _ = rtb.getCoreBasisTerm(e3, r, s, deriv) return } e3sf := func(r, s float64, deriv DerivativeDirection) (p float64) { _, p = rtb.getCoreBasisTerm(e3, r, s, deriv) return } e4rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p, _ = rtb.getCoreBasisTerm(e4, r, s, deriv) return } e4sf := func(r, s float64, deriv DerivativeDirection) (p float64) { _, p = rtb.getCoreBasisTerm(e4, r, s, deriv) return } e5rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p, _ = rtb.getCoreBasisTerm(e5, r, s, deriv) return } e5sf := func(r, s float64, deriv DerivativeDirection) (p float64) { _, p = rtb.getCoreBasisTerm(e5, r, s, deriv) return } l1f := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.LinearPoly(r, s, 0, deriv) return } l2f := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.LinearPoly(r, s, 1, deriv) return } l3f := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.LinearPoly(r, s, 2, deriv) return } q1rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.Lagrange1DPoly(r, RGauss, 0, RDir, deriv) return } q2rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.Lagrange1DPoly(r, RGauss, 1, RDir, deriv) return } q3rf := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.Lagrange1DPoly(r, RGauss, 2, RDir, deriv) return } q1sf := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.Lagrange1DPoly(r, RGauss, 0, SDir, deriv) return } q2sf := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.Lagrange1DPoly(r, RGauss, 1, SDir, deriv) return } q3sf := func(r, s float64, deriv DerivativeDirection) (p float64) { p = rtb.Lagrange1DPoly(r, RGauss, 2, SDir, deriv) return } CRP := func(pL, dpL, pR, dpR float64) (dp float64) { // Chain Rule Product d(P*F)/dr = F*(dP/dr)+ P*(dF/dr) dp = dpL*pR + pL*dpR return } CRP1 := func(r, s float64, deriv DerivativeDirection, left, right func(r, s float64, deriv DerivativeDirection) (p float64)) (p float64) { l := left(r, s, None) ld := left(r, s, deriv) rt := right(r, s, None) rtd := right(r, s, deriv) p = CRP(l, ld, rt, rtd) return } p0, p1 = make([]float64, rtb.Np), make([]float64, rtb.Np) var sk int /* The first three element degrees, P=[0,1,2] are covered by special case code Degrees equal and higher to P=3 use a slightly different scalar basis than the special case code. We use our Lagrange or Jacobi basis for P=[3...], which means there's a difference between quadratic and higher elements that needs some documentation... */ // Non-normal basis functions first switch rtb.P { case 0: // No "non-Normal" basis functions case 1: // Two basis functions, basics e4 and e5 p0[sk], p1[sk] = rtb.getCoreBasisTerm(e4, r, s, deriv) sk++ p0[sk], p1[sk] = rtb.getCoreBasisTerm(e5, r, s, deriv) sk++ case 2: // Six "non-Normal" basis functions, use linear 2D polynomial for triangles multiplied by e4 and e5 if deriv == None { e4r, e4s := rtb.getCoreBasisTerm(e4, r, s) e5r, e5s := rtb.getCoreBasisTerm(e5, r, s) l1 := rtb.LinearPoly(r, s, 0) l2 := rtb.LinearPoly(r, s, 1) l3 := rtb.LinearPoly(r, s, 2) p0[sk], p1[sk] = e4r*l1, e4s*l1 sk++ p0[sk], p1[sk] = e4r*l2, e4s*l2 sk++ p0[sk], p1[sk] = e4r*l3, e4s*l3 sk++ p0[sk], p1[sk] = e5r*l1, e5s*l1 sk++ p0[sk], p1[sk] = e5r*l2, e5s*l2 sk++ p0[sk], p1[sk] = e5r*l3, e5s*l3 sk++ } else { // This covers either derivative direction, Dr or Ds p0[sk], p1[sk] = CRP1(r, s, deriv, e4rf, l1f), CRP1(r, s, deriv, e4sf, l1f) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e4rf, l2f), CRP1(r, s, deriv, e4sf, l2f) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e4rf, l3f), CRP1(r, s, deriv, e4sf, l3f) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e5rf, l1f), CRP1(r, s, deriv, e5sf, l1f) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e5rf, l2f), CRP1(r, s, deriv, e5sf, l2f) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e5rf, l3f), CRP1(r, s, deriv, e5sf, l3f) sk++ } default: e4r, e4s := rtb.getCoreBasisTerm(e4, r, s) e5r, e5s := rtb.getCoreBasisTerm(e5, r, s) var ( e4Rderiv, e4Sderiv, e5Rderiv, e5Sderiv float64 ) if deriv != None { e4Rderiv, e4Sderiv = rtb.getCoreBasisTerm(e4, r, s, deriv) e5Rderiv, e5Sderiv = rtb.getCoreBasisTerm(e5, r, s, deriv) } Pint := rtb.P - 1 for i := 0; i <= Pint; i++ { for j := 0; j <= Pint-i; j++ { p := Basis2DTerm(r, s, i, j, None) if deriv == None { p0[sk], p1[sk] = p*e4r, p*e4s sk++ p0[sk], p1[sk] = p*e5r, p*e5s sk++ } else { dpdr := Basis2DTerm(r, s, i, j, deriv) p0[sk], p1[sk] = CRP(e4r, e4Rderiv, p, dpdr), CRP(e4s, e4Sderiv, p, dpdr) sk++ p0[sk], p1[sk] = CRP(e5r, e5Rderiv, p, dpdr), CRP(e5s, e5Sderiv, p, dpdr) sk++ } } } } /* Now we do the "Normal" basis functions associated with the edges These use the 1D Lagrange polynomials multiplied by the core basis functions */ switch rtb.P { case 0: p0[sk], p1[sk] = rtb.getCoreBasisTerm(e1, r, s, deriv) sk++ p0[sk], p1[sk] = rtb.getCoreBasisTerm(e2, r, s, deriv) sk++ p0[sk], p1[sk] = rtb.getCoreBasisTerm(e3, r, s, deriv) sk++ case 1: if deriv == None { e1r, e1s := rtb.getCoreBasisTerm(e1, r, s) e2r, e2s := rtb.getCoreBasisTerm(e2, r, s) e3r, e3s := rtb.getCoreBasisTerm(e3, r, s) l1xi := rtb.Lagrange1DPoly(r, RGauss, 0, RDir) l2xi := rtb.Lagrange1DPoly(r, RGauss, 1, RDir) l1eta := rtb.Lagrange1DPoly(s, RGauss, 0, SDir) l2eta := rtb.Lagrange1DPoly(s, RGauss, 1, SDir) p0[sk], p1[sk] = l1eta*e1r, l1eta*e1s sk++ p0[sk], p1[sk] = l2eta*e1r, l2eta*e1s sk++ p0[sk], p1[sk] = l2eta*e2r, l2eta*e2s sk++ p0[sk], p1[sk] = l1eta*e2r, l1eta*e2s sk++ p0[sk], p1[sk] = l1xi*e3r, l1xi*e3s sk++ p0[sk], p1[sk] = l2xi*e3r, l2xi*e3s sk++ } else { p0[sk], p1[sk] = CRP1(r, s, deriv, e1rf, q1sf), CRP1(r, s, deriv, e1sf, q1sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e1rf, q2sf), CRP1(r, s, deriv, e1sf, q2sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e2rf, q2sf), CRP1(r, s, deriv, e2sf, q2sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e2rf, q1sf), CRP1(r, s, deriv, e2sf, q1sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e3rf, q1rf), CRP1(r, s, deriv, e3sf, q1rf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e3rf, q2rf), CRP1(r, s, deriv, e3sf, q2rf) sk++ } case 2: if deriv == None { e1r, e1s := rtb.getCoreBasisTerm(e1, r, s) e2r, e2s := rtb.getCoreBasisTerm(e2, r, s) e3r, e3s := rtb.getCoreBasisTerm(e3, r, s) q1xi := rtb.Lagrange1DPoly(r, RGauss, 0, RDir) q2xi := rtb.Lagrange1DPoly(r, RGauss, 1, RDir) q3xi := rtb.Lagrange1DPoly(r, RGauss, 2, RDir) q1eta := rtb.Lagrange1DPoly(s, RGauss, 0, SDir) q2eta := rtb.Lagrange1DPoly(s, RGauss, 1, SDir) q3eta := rtb.Lagrange1DPoly(s, RGauss, 2, SDir) p0[sk], p1[sk] = q1eta*e1r, q1eta*e1s sk++ p0[sk], p1[sk] = q2eta*e1r, q2eta*e1s sk++ p0[sk], p1[sk] = q3eta*e1r, q3eta*e1s sk++ p0[sk], p1[sk] = q3eta*e2r, q3eta*e2s sk++ p0[sk], p1[sk] = q2eta*e2r, q2eta*e2s sk++ p0[sk], p1[sk] = q1eta*e2r, q1eta*e2s sk++ p0[sk], p1[sk] = q1xi*e3r, q1xi*e3s sk++ p0[sk], p1[sk] = q2xi*e3r, q2xi*e3s sk++ p0[sk], p1[sk] = q3xi*e3r, q3xi*e3s sk++ } else { p0[sk], p1[sk] = CRP1(r, s, deriv, e1rf, q1sf), CRP1(r, s, deriv, e1sf, q1sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e1rf, q2sf), CRP1(r, s, deriv, e1sf, q2sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e1rf, q3sf), CRP1(r, s, deriv, e1sf, q3sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e2rf, q3sf), CRP1(r, s, deriv, e2sf, q3sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e2rf, q2sf), CRP1(r, s, deriv, e2sf, q2sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e2rf, q1sf), CRP1(r, s, deriv, e2sf, q1sf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e3rf, q1rf), CRP1(r, s, deriv, e3sf, q1rf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e3rf, q2rf), CRP1(r, s, deriv, e3sf, q2rf) sk++ p0[sk], p1[sk] = CRP1(r, s, deriv, e3rf, q3rf), CRP1(r, s, deriv, e3sf, q3rf) sk++ } default: e1r, e1s := rtb.getCoreBasisTerm(e1, r, s) e2r, e2s := rtb.getCoreBasisTerm(e2, r, s) e3r, e3s := rtb.getCoreBasisTerm(e3, r, s) if deriv == None { for j := 0; j < rtb.P+1; j++ { leta := rtb.Lagrange1DPoly(s, RGauss, j, SDir) p0[sk], p1[sk] = leta*e1r, leta*e1s sk++ } for j := 0; j < rtb.P+1; j++ { leta := rtb.Lagrange1DPoly(s, RGauss, rtb.P-j, SDir) p0[sk], p1[sk] = leta*e2r, leta*e2s sk++ } for j := 0; j < rtb.P+1; j++ { lxi := rtb.Lagrange1DPoly(r, RGauss, j, RDir) p0[sk], p1[sk] = lxi*e3r, lxi*e3s sk++ } } else { e1Rderiv, e1Sderiv := rtb.getCoreBasisTerm(e1, r, s, deriv) e2Rderiv, e2Sderiv := rtb.getCoreBasisTerm(e2, r, s, deriv) e3Rderiv, e3Sderiv := rtb.getCoreBasisTerm(e3, r, s, deriv) for j := 0; j < rtb.P+1; j++ { leta := rtb.Lagrange1DPoly(s, RGauss, j, SDir) letaDeriv := rtb.Lagrange1DPoly(s, RGauss, j, SDir, deriv) p0[sk], p1[sk] = CRP(e1r, e1Rderiv, leta, letaDeriv), CRP(e1s, e1Sderiv, leta, letaDeriv) sk++ } for j := 0; j < rtb.P+1; j++ { leta := rtb.Lagrange1DPoly(s, RGauss, rtb.P-j, SDir) letaDeriv := rtb.Lagrange1DPoly(s, RGauss, rtb.P-j, SDir, deriv) p0[sk], p1[sk] = CRP(e2r, e2Rderiv, leta, letaDeriv), CRP(e2s, e2Sderiv, leta, letaDeriv) sk++ } for j := 0; j < rtb.P+1; j++ { lxi := rtb.Lagrange1DPoly(r, RGauss, j, RDir) lxiDeriv := rtb.Lagrange1DPoly(r, RGauss, j, RDir, deriv) p0[sk], p1[sk] = CRP(e3r, e3Rderiv, lxi, lxiDeriv), CRP(e3s, e3Sderiv, lxi, lxiDeriv) sk++ } } } return } func (rtb *RTBasis2DSimplex) CalculateBasis() { /* We follow the basis function construction of <NAME> "Computational Bases for RTk and BDMk on Triangles" */ var ( Np = rtb.Np Rd, Sd = rtb.R.DataP, rtb.S.DataP p0, p1 []float64 ) P := utils.NewMatrix(Np, Np) if len(Rd) != Np { err := fmt.Errorf("calculated dimension %d doesn't match length of basis nodes %d", Np, len(Rd)) panic(err) } // Evaluate at geometric locations rowEdge := make([]float64, Np) oosr2 := 1. / math.Sqrt(2) for ii, rr := range Rd { ss := Sd[ii] /* First, evaluate the polynomial at the (r,s) coordinates This is the same set that will be used for all dot products to form the basis matrix */ p0, p1 = rtb.EvaluateBasisAtLocation(rr, ss) // Implement dot product of (unit vector)_ii with each vector term in the polynomial evaluated at location ii switch rtb.getLocationType(ii) { case InteriorR: // Unit vector is [1,0] P.M.SetRow(ii, p0) case InteriorS: // Unit vector is [0,1] P.M.SetRow(ii, p1) case Edge1: for i := range rowEdge { // Edge3: // Unit vector is [0,-1] rowEdge[i] = -p1[i] } P.M.SetRow(ii, rowEdge) case Edge2: for i := range rowEdge { // Edge1: Unit vector is [1/sqrt(2), 1/sqrt(2)] rowEdge[i] = oosr2 * (p0[i] + p1[i]) } P.M.SetRow(ii, rowEdge) case Edge3: for i := range rowEdge { // Edge2: Unit vector is [-1,0] rowEdge[i] = -p0[i] } P.M.SetRow(ii, rowEdge) } } // Invert [P] = [A] to obtain the coefficients (columns) of polynomials (rows), each row is a polynomial A := P.InverseWithCheck() // Evaluate 2D polynomial basis at geometric locations, also evaluate derivatives Dr and Ds for Rd and Sd P0, P1 := utils.NewMatrix(Np, Np), utils.NewMatrix(Np, Np) Pdr0, Pds1 := utils.NewMatrix(Np, Np), utils.NewMatrix(Np, Np) for ii, rr := range rtb.R.DataP { ss := rtb.S.DataP[ii] p0, p1 = rtb.EvaluateBasisAtLocation(rr, ss) // each of p1,p2 stores the polynomial terms for the Rd and Sd directions P0.M.SetRow(ii, p0) P1.M.SetRow(ii, p1) p0, _ = rtb.EvaluateBasisAtLocation(rr, ss, Dr) // each of p0,p1 stores the polynomial terms for the Rd and Sd directions _, p1 = rtb.EvaluateBasisAtLocation(rr, ss, Ds) // each of p0,p1 stores the polynomial terms for the Rd and Sd directions Pdr0.M.SetRow(ii, p0) // Only need the dP/dr(r) term from P(r,s) Pds1.M.SetRow(ii, p1) // Only need the dP/ds(s) term from P(r,s) } // Construct the Vandermonde matrices for each direction by multiplying coefficients of constrained basis rtb.V[0] = P0.Mul(A) rtb.V[1] = P1.Mul(A) rtb.Div = Pdr0.Mul(A).Add(Pds1.Mul(A)) if rtb.P != 0 { rtb.DivInt = utils.NewMatrix(rtb.NpInt, Np) for i := 0; i < rtb.NpInt; i++ { rtb.DivInt.M.SetRow(i, rtb.Div.Row(i).DataP) } } return } func (rtb *RTBasis2DSimplex) ExtendGeomToRT(Rint, Sint utils.Vector) (R, S utils.Vector) { var ( N = rtb.P NpEdge = N + 1 rData, sData = Rint.DataP, Sint.DataP Rd, Sd []float64 ) /* Determine geometric locations of edge points, located at Gauss locations in 1D, projected onto the edges */ GQR := utils.NewVector(N+1, DG1D.LegendreZeros(N)) /* Double the number of interior points to match each direction of the basis */ if N == 0 { // Special case: when N=0, the interior of the RT element is empty Rd, Sd = []float64{}, []float64{} } else { for i := 0; i < 2; i++ { Rd = append(Rd, rData...) Sd = append(Sd, sData...) } } // Calculate the triangle edges GQRData := GQR.DataP rEdgeData := make([]float64, NpEdge*3) sEdgeData := make([]float64, NpEdge*3) for i := 0; i < NpEdge; i++ { gp := GQRData[i] // Edge 1 rEdgeData[i] = gp sEdgeData[i] = -1 // Edge 2 (hypotenuse) gpT := 0.5 * (gp + 1) rEdgeData[i+NpEdge] = 1 - 2*gpT sEdgeData[i+NpEdge] = -1 + 2*gpT // Edge 3 rEdgeData[i+2*NpEdge] = -1 sEdgeData[i+2*NpEdge] = -gp } Rd = append(Rd, rEdgeData...) Sd = append(Sd, sEdgeData...) nn := len(Rd) R, S = utils.NewVector(nn, Rd), utils.NewVector(nn, Sd) return } func (rtb *RTBasis2DSimplex) GetEdgeLocations(F []float64) (Fedge []float64) { var ( Nint = rtb.NpInt NedgeTot = rtb.NpEdge * 3 ) Fedge = make([]float64, NedgeTot) for i := 0; i < NedgeTot; i++ { Fedge[i] = F[i+2*Nint] } return } func (rtb *RTBasis2DSimplex) GetInternalLocations(F []float64) (Finternal []float64) { var ( Nint = rtb.NpInt ) Finternal = make([]float64, Nint) for i := 0; i < Nint; i++ { Finternal[i] = F[i] } return } /* Set up the five core vector basis functions used for all order of terms */ type TermType uint8 const ( e1 TermType = iota e2 e3 e4 e5 ) func (rtb *RTBasis2DSimplex) getCoreBasisTerm(tt TermType, r, s float64, derivO ...DerivativeDirection) (p0, p1 float64) { var ( sr2 = math.Sqrt(2) oosr2 = 1. / sr2 deriv DerivativeDirection ) if len(derivO) != 0 { deriv = derivO[0] } else { deriv = None } switch tt { case e1: switch deriv { case None: //p0 = sr2 * xi //p1 = sr2 * eta p0 = oosr2 * (r + 1) p1 = oosr2 * (s + 1) case Dr: p0 = oosr2 case Ds: p1 = oosr2 } case e2: switch deriv { case None: //p0 = xi - 1 //p1 = eta p0 = 0.5*r - 0.5 p1 = 0.5*s + 0.5 case Dr: p0 = 0.5 case Ds: p1 = 0.5 } case e3: switch deriv { case None: //p0 = xi //p1 = eta - 1 p0 = 0.5*r + 0.5 p1 = 0.5*s - 0.5 case Dr: p0 = 0.5 case Ds: p1 = 0.5 } case e4: switch deriv { case None: //p0 = eta * xi //p1 = eta * (eta - 1) p0 = 0.25 * (r*s + r + s + 1) p1 = 0.25 * (s*s - 1) case Dr: p0 = 0.25 * (s + 1) case Ds: p0 = 0.25 * (r + 1) p1 = 0.5 * s } case e5: switch deriv { case None: //p0 = xi * (xi - 1) //p1 = xi * eta p0 = 0.25 * (r*r - 1) p1 = 0.25 * (r*s + r + s + 1) case Dr: p0 = 0.5 * r p1 = 0.25 * (s + 1) case Ds: p1 = 0.25 * (r + 1) } } return } type Direction uint8 const ( RDir Direction = iota SDir ) func (rtb *RTBasis2DSimplex) Lagrange1DPoly(r float64, R []float64, j int, dir Direction, derivO ...DerivativeDirection) (p float64) { // This is a 1D polynomial, but the nodes are either in the RDir or SDir direction within 2D var ( deriv DerivativeDirection ) if len(derivO) != 0 { deriv = derivO[0] } else { deriv = None } switch deriv { case None: var ( Np1D = len(R) XJ = R[j] XI = r ) if j > Np1D-1 || j < 0 { panic("value of j larger than array or less than zero") } p = 1 for m, XM := range R { if m != j { p *= (XI - XM) / (XJ - XM) } } case Dr, Ds: switch { case dir == SDir && deriv == Dr: return case dir == RDir && deriv == Ds: return } /* From https://en.wikipedia.org/wiki/Lagrange_polynomial#Derivatives */ var ( XJ = R[j] X = r ) for i, XI := range R { if i != j { pp := 1. for m, XM := range R { if m != i && m != j { pp *= (X - XM) / (XJ - XM) } } p += pp / (XJ - XI) } } } return } func (rtb *RTBasis2DSimplex) LinearPoly(r, s float64, j int, derivO ...DerivativeDirection) (p float64) { var ( deriv DerivativeDirection ) if j > 2 || j < 0 { err := fmt.Errorf("linear 2D polynomial called with bad parameters [j]=[%d]", j) panic(err) } if len(derivO) != 0 { deriv = derivO[0] } else { deriv = None } switch deriv { case None: switch j { case 0: p = -0.5 * (r + s) case 1: p = 0.5*r + 0.5 case 2: p = 0.5*s + 0.5 } case Dr: switch j { case 0: p = -0.5 case 1: p = 0.5 case 2: p = 0 } case Ds: switch j { case 0: p = -0.5 case 1: p = 0 case 2: p = 0.5 } } return }
DG2D/RTElement.go
0.640973
0.657318
RTElement.go
starcoder
package factMapper // tracker is a simple module that maps from a set of facts to a set of labels // based on a set of supplied mapping rules. type tracker struct { // lookup tables derived from the current mapping rules tables *lookupTables // the current set of known facts currentFacts map[string]string // the current set of known labels, corresponding to mapping of the known facts through the selector currentLabels map[string]string // Accumulates the set of labels that need to be updated, given fact or config changes labelsToRefresh []string } // newTracker returns a new independent tracker instance. func newTracker(tables *lookupTables) *tracker { return &tracker{ tables: tables, currentFacts: make(map[string]string), currentLabels: make(map[string]string)} } // refreshLabels refreshes the labels in need of update func (t *tracker) refreshLabels() { for _, label := range t.labelsToRefresh { facts := t.tables.labelFacts[label] t.currentLabels[label] = "" for _, fact := range facts { value, ok := t.currentFacts[fact] if ok { t.currentLabels[label] = value break } } } // all up to date t.labelsToRefresh = t.labelsToRefresh[:0] } func (t *tracker) UpdateFacts(facts map[string]string) { // update our known facts and keep track of the labels that need refreshing for fact, value := range facts { t.currentFacts[fact] = value for _, label := range t.tables.factLabels[fact] { t.labelsToRefresh = append(t.labelsToRefresh, label) } } } func (t *tracker) PurgeFacts(facts []string) { // update the known facts and keep track of the labels that need refreshing for _, fact := range facts { delete(t.currentFacts, fact) for _, label := range t.tables.factLabels[fact] { t.labelsToRefresh = append(t.labelsToRefresh, label) } } } func (t *tracker) GetLabels() map[string]string { t.refreshLabels() return t.currentLabels } func (t *tracker) Reset() { // nuke all the facts for k := range t.currentFacts { delete(t.currentFacts, k) } // and nuke all the labels for k := range t.currentLabels { delete(t.currentLabels, k) } t.labelsToRefresh = t.labelsToRefresh[:0] } func (t *tracker) Stats() (numFacts int, numLabels int) { return len(t.currentFacts), len(t.currentLabels) }
adapters/factMapper/tracker.go
0.720368
0.591723
tracker.go
starcoder
package encoding // Data tables for 4-byte characters in GB18030 encoding. // Based on http://source.icu-project.org/repos/icu/data/trunk/charset/data/ucm/gb-18030-2005.ucm // gb18030Linear converts a 32-bit big-endian representation of a 4-byte // character into a linearly-increasing integer, starting from the base // sequence of 0x81308130 func gb18030Linear(g uint32) uint32 { lin := g>>24 - 0x81 lin = lin*10 + (g>>16)&0xff - 0x30 lin = lin*126 + (g>>8)&0xff - 0x81 lin = lin*10 + g&0xff - 0x30 return lin } // Equivalent ranges between GB18030 and Unicode. var gb18030Ranges = []struct { firstRune, lastRune rune firstGB, lastGB uint32 }{ {0x10000, 0x10FFFF, gb18030Linear(0x90308130), gb18030Linear(0xE3329A35)}, {0x9FA6, 0xD7FF, gb18030Linear(0x82358F33), gb18030Linear(0x8336C738)}, {0x0452, 0x200F, gb18030Linear(0x8130D330), gb18030Linear(0x8136A531)}, {0xE865, 0xF92B, gb18030Linear(0x8336D030), gb18030Linear(0x84308534)}, {0x2643, 0x2E80, gb18030Linear(0x8137A839), gb18030Linear(0x8138FD38)}, {0xFA2A, 0xFE2F, gb18030Linear(0x84309C38), gb18030Linear(0x84318537)}, {0x3CE1, 0x4055, gb18030Linear(0x8231D438), gb18030Linear(0x8232AF32)}, {0x361B, 0x3917, gb18030Linear(0x8230A633), gb18030Linear(0x8230F237)}, {0x49B8, 0x4C76, gb18030Linear(0x8234A131), gb18030Linear(0x8234E733)}, {0x4160, 0x4336, gb18030Linear(0x8232C937), gb18030Linear(0x8232F837)}, {0x478E, 0x4946, gb18030Linear(0x8233E838), gb18030Linear(0x82349638)}, {0x44D7, 0x464B, gb18030Linear(0x8233A339), gb18030Linear(0x8233C931)}, {0xFFE6, 0xFFFF, gb18030Linear(0x8431A234), gb18030Linear(0x8431A439)}, } // The higest value returned by gb18030Linear for characters in gb18030Data const maxGB18030Linear = 39393 // Unicode equivalents for characters not handled algorithmically. var gb18030Data = []struct { unicode uint16 gb18030 uint32 }{ {0x0080, 0x81308130}, {0x0081, 0x81308131}, {0x0082, 0x81308132}, {0x0083, 0x81308133}, {0x0084, 0x81308134}, {0x0085, 0x81308135}, {0x0086, 0x81308136}, {0x0087, 0x81308137}, {0x0088, 0x81308138}, {0x0089, 0x81308139}, {0x008A, 0x81308230}, {0x008B, 0x81308231}, {0x008C, 0x81308232}, {0x008D, 0x81308233}, {0x008E, 0x81308234}, {0x008F, 0x81308235}, {0x0090, 0x81308236}, {0x0091, 0x81308237}, {0x0092, 0x81308238}, {0x0093, 0x81308239}, {0x0094, 0x81308330}, {0x0095, 0x81308331}, {0x0096, 0x81308332}, {0x0097, 0x81308333}, {0x0098, 0x81308334}, {0x0099, 0x81308335}, {0x009A, 0x81308336}, {0x009B, 0x81308337}, {0x009C, 0x81308338}, {0x009D, 0x81308339}, {0x009E, 0x81308430}, {0x009F, 0x81308431}, {0x00A0, 0x81308432}, {0x00A1, 0x81308433}, {0x00A2, 0x81308434}, {0x00A3, 0x81308435}, {0x00A5, 0x81308436}, {0x00A6, 0x81308437}, {0x00A9, 0x81308438}, {0x00AA, 0x81308439}, {0x00AB, 0x81308530}, {0x00AC, 0x81308531}, {0x00AD, 0x81308532}, {0x00AE, 0x81308533}, {0x00AF, 0x81308534}, {0x00B2, 0x81308535}, {0x00B3, 0x81308536}, {0x00B4, 0x81308537}, {0x00B5, 0x81308538}, {0x00B6, 0x81308539}, {0x00B8, 0x81308630}, {0x00B9, 0x81308631}, {0x00BA, 0x81308632}, {0x00BB, 0x81308633}, {0x00BC, 0x81308634}, {0x00BD, 0x81308635}, {0x00BE, 0x81308636}, {0x00BF, 0x81308637}, {0x00C0, 0x81308638}, {0x00C1, 0x81308639}, {0x00C2, 0x81308730}, {0x00C3, 0x81308731}, {0x00C4, 0x81308732}, {0x00C5, 0x81308733}, {0x00C6, 0x81308734}, {0x00C7, 0x81308735}, {0x00C8, 0x81308736}, {0x00C9, 0x81308737}, {0x00CA, 0x81308738}, {0x00CB, 0x81308739}, {0x00CC, 0x81308830}, {0x00CD, 0x81308831}, {0x00CE, 0x81308832}, {0x00CF, 0x81308833}, {0x00D0, 0x81308834}, {0x00D1, 0x81308835}, {0x00D2, 0x81308836}, {0x00D3, 0x81308837}, {0x00D4, 0x81308838}, {0x00D5, 0x81308839}, {0x00D6, 0x81308930}, {0x00D8, 0x81308931}, {0x00D9, 0x81308932}, {0x00DA, 0x81308933}, {0x00DB, 0x81308934}, {0x00DC, 0x81308935}, {0x00DD, 0x81308936}, {0x00DE, 0x81308937}, {0x00DF, 0x81308938}, {0x00E2, 0x81308939}, {0x00E3, 0x81308A30}, {0x00E4, 0x81308A31}, {0x00E5, 0x81308A32}, {0x00E6, 0x81308A33}, {0x00E7, 0x81308A34}, {0x00EB, 0x81308A35}, {0x00EE, 0x81308A36}, {0x00EF, 0x81308A37}, {0x00F0, 0x81308A38}, {0x00F1, 0x81308A39}, {0x00F4, 0x81308B30}, {0x00F5, 0x81308B31}, {0x00F6, 0x81308B32}, {0x00F8, 0x81308B33}, {0x00FB, 0x81308B34}, {0x00FD, 0x81308B35}, {0x00FE, 0x81308B36}, {0x00FF, 0x81308B37}, {0x0100, 0x81308B38}, {0x0102, 0x81308B39}, {0x0103, 0x81308C30}, {0x0104, 0x81308C31}, {0x0105, 0x81308C32}, {0x0106, 0x81308C33}, {0x0107, 0x81308C34}, {0x0108, 0x81308C35}, {0x0109, 0x81308C36}, {0x010A, 0x81308C37}, {0x010B, 0x81308C38}, {0x010C, 0x81308C39}, {0x010D, 0x81308D30}, {0x010E, 0x81308D31}, {0x010F, 0x81308D32}, {0x0110, 0x81308D33}, {0x0111, 0x81308D34}, {0x0112, 0x81308D35}, {0x0114, 0x81308D36}, {0x0115, 0x81308D37}, {0x0116, 0x81308D38}, {0x0117, 0x81308D39}, {0x0118, 0x81308E30}, {0x0119, 0x81308E31}, {0x011A, 0x81308E32}, {0x011C, 0x81308E33}, {0x011D, 0x81308E34}, {0x011E, 0x81308E35}, {0x011F, 0x81308E36}, {0x0120, 0x81308E37}, {0x0121, 0x81308E38}, {0x0122, 0x81308E39}, {0x0123, 0x81308F30}, {0x0124, 0x81308F31}, {0x0125, 0x81308F32}, {0x0126, 0x81308F33}, {0x0127, 0x81308F34}, {0x0128, 0x81308F35}, {0x0129, 0x81308F36}, {0x012A, 0x81308F37}, {0x012C, 0x81308F38}, {0x012D, 0x81308F39}, {0x012E, 0x81309030}, {0x012F, 0x81309031}, {0x0130, 0x81309032}, {0x0131, 0x81309033}, {0x0132, 0x81309034}, {0x0133, 0x81309035}, {0x0134, 0x81309036}, {0x0135, 0x81309037}, {0x0136, 0x81309038}, {0x0137, 0x81309039}, {0x0138, 0x81309130}, {0x0139, 0x81309131}, {0x013A, 0x81309132}, {0x013B, 0x81309133}, {0x013C, 0x81309134}, {0x013D, 0x81309135}, {0x013E, 0x81309136}, {0x013F, 0x81309137}, {0x0140, 0x81309138}, {0x0141, 0x81309139}, {0x0142, 0x81309230}, {0x0143, 0x81309231}, {0x0145, 0x81309232}, {0x0146, 0x81309233}, {0x0147, 0x81309234}, {0x0149, 0x81309235}, {0x014A, 0x81309236}, {0x014B, 0x81309237}, {0x014C, 0x81309238}, {0x014E, 0x81309239}, {0x014F, 0x81309330}, {0x0150, 0x81309331}, {0x0151, 0x81309332}, {0x0152, 0x81309333}, {0x0153, 0x81309334}, {0x0154, 0x81309335}, {0x0155, 0x81309336}, {0x0156, 0x81309337}, {0x0157, 0x81309338}, {0x0158, 0x81309339}, {0x0159, 0x81309430}, {0x015A, 0x81309431}, {0x015B, 0x81309432}, {0x015C, 0x81309433}, {0x015D, 0x81309434}, {0x015E, 0x81309435}, {0x015F, 0x81309436}, {0x0160, 0x81309437}, {0x0161, 0x81309438}, {0x0162, 0x81309439}, {0x0163, 0x81309530}, {0x0164, 0x81309531}, {0x0165, 0x81309532}, {0x0166, 0x81309533}, {0x0167, 0x81309534}, {0x0168, 0x81309535}, {0x0169, 0x81309536}, {0x016A, 0x81309537}, {0x016C, 0x81309538}, {0x016D, 0x81309539}, {0x016E, 0x81309630}, {0x016F, 0x81309631}, {0x0170, 0x81309632}, {0x0171, 0x81309633}, {0x0172, 0x81309634}, {0x0173, 0x81309635}, {0x0174, 0x81309636}, {0x0175, 0x81309637}, {0x0176, 0x81309638}, {0x0177, 0x81309639}, {0x0178, 0x81309730}, {0x0179, 0x81309731}, {0x017A, 0x81309732}, {0x017B, 0x81309733}, {0x017C, 0x81309734}, {0x017D, 0x81309735}, {0x017E, 0x81309736}, {0x017F, 0x81309737}, {0x0180, 0x81309738}, {0x0181, 0x81309739}, {0x0182, 0x81309830}, {0x0183, 0x81309831}, {0x0184, 0x81309832}, {0x0185, 0x81309833}, {0x0186, 0x81309834}, {0x0187, 0x81309835}, {0x0188, 0x81309836}, {0x0189, 0x81309837}, {0x018A, 0x81309838}, {0x018B, 0x81309839}, {0x018C, 0x81309930}, {0x018D, 0x81309931}, {0x018E, 0x81309932}, {0x018F, 0x81309933}, {0x0190, 0x81309934}, {0x0191, 0x81309935}, {0x0192, 0x81309936}, {0x0193, 0x81309937}, {0x0194, 0x81309938}, {0x0195, 0x81309939}, {0x0196, 0x81309A30}, {0x0197, 0x81309A31}, {0x0198, 0x81309A32}, {0x0199, 0x81309A33}, {0x019A, 0x81309A34}, {0x019B, 0x81309A35}, {0x019C, 0x81309A36}, {0x019D, 0x81309A37}, {0x019E, 0x81309A38}, {0x019F, 0x81309A39}, {0x01A0, 0x81309B30}, {0x01A1, 0x81309B31}, {0x01A2, 0x81309B32}, {0x01A3, 0x81309B33}, {0x01A4, 0x81309B34}, {0x01A5, 0x81309B35}, {0x01A6, 0x81309B36}, {0x01A7, 0x81309B37}, {0x01A8, 0x81309B38}, {0x01A9, 0x81309B39}, {0x01AA, 0x81309C30}, {0x01AB, 0x81309C31}, {0x01AC, 0x81309C32}, {0x01AD, 0x81309C33}, {0x01AE, 0x81309C34}, {0x01AF, 0x81309C35}, {0x01B0, 0x81309C36}, {0x01B1, 0x81309C37}, {0x01B2, 0x81309C38}, {0x01B3, 0x81309C39}, {0x01B4, 0x81309D30}, {0x01B5, 0x81309D31}, {0x01B6, 0x81309D32}, {0x01B7, 0x81309D33}, {0x01B8, 0x81309D34}, {0x01B9, 0x81309D35}, {0x01BA, 0x81309D36}, {0x01BB, 0x81309D37}, {0x01BC, 0x81309D38}, {0x01BD, 0x81309D39}, {0x01BE, 0x81309E30}, {0x01BF, 0x81309E31}, {0x01C0, 0x81309E32}, {0x01C1, 0x81309E33}, {0x01C2, 0x81309E34}, {0x01C3, 0x81309E35}, {0x01C4, 0x81309E36}, {0x01C5, 0x81309E37}, {0x01C6, 0x81309E38}, {0x01C7, 0x81309E39}, {0x01C8, 0x81309F30}, {0x01C9, 0x81309F31}, {0x01CA, 0x81309F32}, {0x01CB, 0x81309F33}, {0x01CC, 0x81309F34}, {0x01CD, 0x81309F35}, {0x01CF, 0x81309F36}, {0x01D1, 0x81309F37}, {0x01D3, 0x81309F38}, {0x01D5, 0x81309F39}, {0x01D7, 0x8130A030}, {0x01D9, 0x8130A031}, {0x01DB, 0x8130A032}, {0x01DD, 0x8130A033}, {0x01DE, 0x8130A034}, {0x01DF, 0x8130A035}, {0x01E0, 0x8130A036}, {0x01E1, 0x8130A037}, {0x01E2, 0x8130A038}, {0x01E3, 0x8130A039}, {0x01E4, 0x8130A130}, {0x01E5, 0x8130A131}, {0x01E6, 0x8130A132}, {0x01E7, 0x8130A133}, {0x01E8, 0x8130A134}, {0x01E9, 0x8130A135}, {0x01EA, 0x8130A136}, {0x01EB, 0x8130A137}, {0x01EC, 0x8130A138}, {0x01ED, 0x8130A139}, {0x01EE, 0x8130A230}, {0x01EF, 0x8130A231}, {0x01F0, 0x8130A232}, {0x01F1, 0x8130A233}, {0x01F2, 0x8130A234}, {0x01F3, 0x8130A235}, {0x01F4, 0x8130A236}, {0x01F5, 0x8130A237}, {0x01F6, 0x8130A238}, {0x01F7, 0x8130A239}, {0x01F8, 0x8130A330}, {0x01FA, 0x8130A331}, {0x01FB, 0x8130A332}, {0x01FC, 0x8130A333}, {0x01FD, 0x8130A334}, {0x01FE, 0x8130A335}, {0x01FF, 0x8130A336}, {0x0200, 0x8130A337}, {0x0201, 0x8130A338}, {0x0202, 0x8130A339}, {0x0203, 0x8130A430}, {0x0204, 0x8130A431}, {0x0205, 0x8130A432}, {0x0206, 0x8130A433}, {0x0207, 0x8130A434}, {0x0208, 0x8130A435}, {0x0209, 0x8130A436}, {0x020A, 0x8130A437}, {0x020B, 0x8130A438}, {0x020C, 0x8130A439}, {0x020D, 0x8130A530}, {0x020E, 0x8130A531}, {0x020F, 0x8130A532}, {0x0210, 0x8130A533}, {0x0211, 0x8130A534}, {0x0212, 0x8130A535}, {0x0213, 0x8130A536}, {0x0214, 0x8130A537}, {0x0215, 0x8130A538}, {0x0216, 0x8130A539}, {0x0217, 0x8130A630}, {0x0218, 0x8130A631}, {0x0219, 0x8130A632}, {0x021A, 0x8130A633}, {0x021B, 0x8130A634}, {0x021C, 0x8130A635}, {0x021D, 0x8130A636}, {0x021E, 0x8130A637}, {0x021F, 0x8130A638}, {0x0220, 0x8130A639}, {0x0221, 0x8130A730}, {0x0222, 0x8130A731}, {0x0223, 0x8130A732}, {0x0224, 0x8130A733}, {0x0225, 0x8130A734}, {0x0226, 0x8130A735}, {0x0227, 0x8130A736}, {0x0228, 0x8130A737}, {0x0229, 0x8130A738}, {0x022A, 0x8130A739}, {0x022B, 0x8130A830}, {0x022C, 0x8130A831}, {0x022D, 0x8130A832}, {0x022E, 0x8130A833}, {0x022F, 0x8130A834}, {0x0230, 0x8130A835}, {0x0231, 0x8130A836}, {0x0232, 0x8130A837}, {0x0233, 0x8130A838}, {0x0234, 0x8130A839}, {0x0235, 0x8130A930}, {0x0236, 0x8130A931}, {0x0237, 0x8130A932}, {0x0238, 0x8130A933}, {0x0239, 0x8130A934}, {0x023A, 0x8130A935}, {0x023B, 0x8130A936}, {0x023C, 0x8130A937}, {0x023D, 0x8130A938}, {0x023E, 0x8130A939}, {0x023F, 0x8130AA30}, {0x0240, 0x8130AA31}, {0x0241, 0x8130AA32}, {0x0242, 0x8130AA33}, {0x0243, 0x8130AA34}, {0x0244, 0x8130AA35}, {0x0245, 0x8130AA36}, {0x0246, 0x8130AA37}, {0x0247, 0x8130AA38}, {0x0248, 0x8130AA39}, {0x0249, 0x8130AB30}, {0x024A, 0x8130AB31}, {0x024B, 0x8130AB32}, {0x024C, 0x8130AB33}, {0x024D, 0x8130AB34}, {0x024E, 0x8130AB35}, {0x024F, 0x8130AB36}, {0x0250, 0x8130AB37}, {0x0252, 0x8130AB38}, {0x0253, 0x8130AB39}, {0x0254, 0x8130AC30}, {0x0255, 0x8130AC31}, {0x0256, 0x8130AC32}, {0x0257, 0x8130AC33}, {0x0258, 0x8130AC34}, {0x0259, 0x8130AC35}, {0x025A, 0x8130AC36}, {0x025B, 0x8130AC37}, {0x025C, 0x8130AC38}, {0x025D, 0x8130AC39}, {0x025E, 0x8130AD30}, {0x025F, 0x8130AD31}, {0x0260, 0x8130AD32}, {0x0262, 0x8130AD33}, {0x0263, 0x8130AD34}, {0x0264, 0x8130AD35}, {0x0265, 0x8130AD36}, {0x0266, 0x8130AD37}, {0x0267, 0x8130AD38}, {0x0268, 0x8130AD39}, {0x0269, 0x8130AE30}, {0x026A, 0x8130AE31}, {0x026B, 0x8130AE32}, {0x026C, 0x8130AE33}, {0x026D, 0x8130AE34}, {0x026E, 0x8130AE35}, {0x026F, 0x8130AE36}, {0x0270, 0x8130AE37}, {0x0271, 0x8130AE38}, {0x0272, 0x8130AE39}, {0x0273, 0x8130AF30}, {0x0274, 0x8130AF31}, {0x0275, 0x8130AF32}, {0x0276, 0x8130AF33}, {0x0277, 0x8130AF34}, {0x0278, 0x8130AF35}, {0x0279, 0x8130AF36}, {0x027A, 0x8130AF37}, {0x027B, 0x8130AF38}, {0x027C, 0x8130AF39}, {0x027D, 0x8130B030}, {0x027E, 0x8130B031}, {0x027F, 0x8130B032}, {0x0280, 0x8130B033}, {0x0281, 0x8130B034}, {0x0282, 0x8130B035}, {0x0283, 0x8130B036}, {0x0284, 0x8130B037}, {0x0285, 0x8130B038}, {0x0286, 0x8130B039}, {0x0287, 0x8130B130}, {0x0288, 0x8130B131}, {0x0289, 0x8130B132}, {0x028A, 0x8130B133}, {0x028B, 0x8130B134}, {0x028C, 0x8130B135}, {0x028D, 0x8130B136}, {0x028E, 0x8130B137}, {0x028F, 0x8130B138}, {0x0290, 0x8130B139}, {0x0291, 0x8130B230}, {0x0292, 0x8130B231}, {0x0293, 0x8130B232}, {0x0294, 0x8130B233}, {0x0295, 0x8130B234}, {0x0296, 0x8130B235}, {0x0297, 0x8130B236}, {0x0298, 0x8130B237}, {0x0299, 0x8130B238}, {0x029A, 0x8130B239}, {0x029B, 0x8130B330}, {0x029C, 0x8130B331}, {0x029D, 0x8130B332}, {0x029E, 0x8130B333}, {0x029F, 0x8130B334}, {0x02A0, 0x8130B335}, {0x02A1, 0x8130B336}, {0x02A2, 0x8130B337}, {0x02A3, 0x8130B338}, {0x02A4, 0x8130B339}, {0x02A5, 0x8130B430}, {0x02A6, 0x8130B431}, {0x02A7, 0x8130B432}, {0x02A8, 0x8130B433}, {0x02A9, 0x8130B434}, {0x02AA, 0x8130B435}, {0x02AB, 0x8130B436}, {0x02AC, 0x8130B437}, {0x02AD, 0x8130B438}, {0x02AE, 0x8130B439}, {0x02AF, 0x8130B530}, {0x02B0, 0x8130B531}, {0x02B1, 0x8130B532}, {0x02B2, 0x8130B533}, {0x02B3, 0x8130B534}, {0x02B4, 0x8130B535}, {0x02B5, 0x8130B536}, {0x02B6, 0x8130B537}, {0x02B7, 0x8130B538}, {0x02B8, 0x8130B539}, {0x02B9, 0x8130B630}, {0x02BA, 0x8130B631}, {0x02BB, 0x8130B632}, {0x02BC, 0x8130B633}, {0x02BD, 0x8130B634}, {0x02BE, 0x8130B635}, {0x02BF, 0x8130B636}, {0x02C0, 0x8130B637}, {0x02C1, 0x8130B638}, {0x02C2, 0x8130B639}, {0x02C3, 0x8130B730}, {0x02C4, 0x8130B731}, {0x02C5, 0x8130B732}, {0x02C6, 0x8130B733}, {0x02C8, 0x8130B734}, {0x02CC, 0x8130B735}, {0x02CD, 0x8130B736}, {0x02CE, 0x8130B737}, {0x02CF, 0x8130B738}, {0x02D0, 0x8130B739}, {0x02D1, 0x8130B830}, {0x02D2, 0x8130B831}, {0x02D3, 0x8130B832}, {0x02D4, 0x8130B833}, {0x02D5, 0x8130B834}, {0x02D6, 0x8130B835}, {0x02D7, 0x8130B836}, {0x02D8, 0x8130B837}, {0x02DA, 0x8130B838}, {0x02DB, 0x8130B839}, {0x02DC, 0x8130B930}, {0x02DD, 0x8130B931}, {0x02DE, 0x8130B932}, {0x02DF, 0x8130B933}, {0x02E0, 0x8130B934}, {0x02E1, 0x8130B935}, {0x02E2, 0x8130B936}, {0x02E3, 0x8130B937}, {0x02E4, 0x8130B938}, {0x02E5, 0x8130B939}, {0x02E6, 0x8130BA30}, {0x02E7, 0x8130BA31}, {0x02E8, 0x8130BA32}, {0x02E9, 0x8130BA33}, {0x02EA, 0x8130BA34}, {0x02EB, 0x8130BA35}, {0x02EC, 0x8130BA36}, {0x02ED, 0x8130BA37}, {0x02EE, 0x8130BA38}, {0x02EF, 0x8130BA39}, {0x02F0, 0x8130BB30}, {0x02F1, 0x8130BB31}, {0x02F2, 0x8130BB32}, {0x02F3, 0x8130BB33}, {0x02F4, 0x8130BB34}, {0x02F5, 0x8130BB35}, {0x02F6, 0x8130BB36}, {0x02F7, 0x8130BB37}, {0x02F8, 0x8130BB38}, {0x02F9, 0x8130BB39}, {0x02FA, 0x8130BC30}, {0x02FB, 0x8130BC31}, {0x02FC, 0x8130BC32}, {0x02FD, 0x8130BC33}, {0x02FE, 0x8130BC34}, {0x02FF, 0x8130BC35}, {0x0300, 0x8130BC36}, {0x0301, 0x8130BC37}, {0x0302, 0x8130BC38}, {0x0303, 0x8130BC39}, {0x0304, 0x8130BD30}, {0x0305, 0x8130BD31}, {0x0306, 0x8130BD32}, {0x0307, 0x8130BD33}, {0x0308, 0x8130BD34}, {0x0309, 0x8130BD35}, {0x030A, 0x8130BD36}, {0x030B, 0x8130BD37}, {0x030C, 0x8130BD38}, {0x030D, 0x8130BD39}, {0x030E, 0x8130BE30}, {0x030F, 0x8130BE31}, {0x0310, 0x8130BE32}, {0x0311, 0x8130BE33}, {0x0312, 0x8130BE34}, {0x0313, 0x8130BE35}, {0x0314, 0x8130BE36}, {0x0315, 0x8130BE37}, {0x0316, 0x8130BE38}, {0x0317, 0x8130BE39}, {0x0318, 0x8130BF30}, {0x0319, 0x8130BF31}, {0x031A, 0x8130BF32}, {0x031B, 0x8130BF33}, {0x031C, 0x8130BF34}, {0x031D, 0x8130BF35}, {0x031E, 0x8130BF36}, {0x031F, 0x8130BF37}, {0x0320, 0x8130BF38}, {0x0321, 0x8130BF39}, {0x0322, 0x8130C030}, {0x0323, 0x8130C031}, {0x0324, 0x8130C032}, {0x0325, 0x8130C033}, {0x0326, 0x8130C034}, {0x0327, 0x8130C035}, {0x0328, 0x8130C036}, {0x0329, 0x8130C037}, {0x032A, 0x8130C038}, {0x032B, 0x8130C039}, {0x032C, 0x8130C130}, {0x032D, 0x8130C131}, {0x032E, 0x8130C132}, {0x032F, 0x8130C133}, {0x0330, 0x8130C134}, {0x0331, 0x8130C135}, {0x0332, 0x8130C136}, {0x0333, 0x8130C137}, {0x0334, 0x8130C138}, {0x0335, 0x8130C139}, {0x0336, 0x8130C230}, {0x0337, 0x8130C231}, {0x0338, 0x8130C232}, {0x0339, 0x8130C233}, {0x033A, 0x8130C234}, {0x033B, 0x8130C235}, {0x033C, 0x8130C236}, {0x033D, 0x8130C237}, {0x033E, 0x8130C238}, {0x033F, 0x8130C239}, {0x0340, 0x8130C330}, {0x0341, 0x8130C331}, {0x0342, 0x8130C332}, {0x0343, 0x8130C333}, {0x0344, 0x8130C334}, {0x0345, 0x8130C335}, {0x0346, 0x8130C336}, {0x0347, 0x8130C337}, {0x0348, 0x8130C338}, {0x0349, 0x8130C339}, {0x034A, 0x8130C430}, {0x034B, 0x8130C431}, {0x034C, 0x8130C432}, {0x034D, 0x8130C433}, {0x034E, 0x8130C434}, {0x034F, 0x8130C435}, {0x0350, 0x8130C436}, {0x0351, 0x8130C437}, {0x0352, 0x8130C438}, {0x0353, 0x8130C439}, {0x0354, 0x8130C530}, {0x0355, 0x8130C531}, {0x0356, 0x8130C532}, {0x0357, 0x8130C533}, {0x0358, 0x8130C534}, {0x0359, 0x8130C535}, {0x035A, 0x8130C536}, {0x035B, 0x8130C537}, {0x035C, 0x8130C538}, {0x035D, 0x8130C539}, {0x035E, 0x8130C630}, {0x035F, 0x8130C631}, {0x0360, 0x8130C632}, {0x0361, 0x8130C633}, {0x0362, 0x8130C634}, {0x0363, 0x8130C635}, {0x0364, 0x8130C636}, {0x0365, 0x8130C637}, {0x0366, 0x8130C638}, {0x0367, 0x8130C639}, {0x0368, 0x8130C730}, {0x0369, 0x8130C731}, {0x036A, 0x8130C732}, {0x036B, 0x8130C733}, {0x036C, 0x8130C734}, {0x036D, 0x8130C735}, {0x036E, 0x8130C736}, {0x036F, 0x8130C737}, {0x0370, 0x8130C738}, {0x0371, 0x8130C739}, {0x0372, 0x8130C830}, {0x0373, 0x8130C831}, {0x0374, 0x8130C832}, {0x0375, 0x8130C833}, {0x0376, 0x8130C834}, {0x0377, 0x8130C835}, {0x0378, 0x8130C836}, {0x0379, 0x8130C837}, {0x037A, 0x8130C838}, {0x037B, 0x8130C839}, {0x037C, 0x8130C930}, {0x037D, 0x8130C931}, {0x037E, 0x8130C932}, {0x037F, 0x8130C933}, {0x0380, 0x8130C934}, {0x0381, 0x8130C935}, {0x0382, 0x8130C936}, {0x0383, 0x8130C937}, {0x0384, 0x8130C938}, {0x0385, 0x8130C939}, {0x0386, 0x8130CA30}, {0x0387, 0x8130CA31}, {0x0388, 0x8130CA32}, {0x0389, 0x8130CA33}, {0x038A, 0x8130CA34}, {0x038B, 0x8130CA35}, {0x038C, 0x8130CA36}, {0x038D, 0x8130CA37}, {0x038E, 0x8130CA38}, {0x038F, 0x8130CA39}, {0x0390, 0x8130CB30}, {0x03A2, 0x8130CB31}, {0x03AA, 0x8130CB32}, {0x03AB, 0x8130CB33}, {0x03AC, 0x8130CB34}, {0x03AD, 0x8130CB35}, {0x03AE, 0x8130CB36}, {0x03AF, 0x8130CB37}, {0x03B0, 0x8130CB38}, {0x03C2, 0x8130CB39}, {0x03CA, 0x8130CC30}, {0x03CB, 0x8130CC31}, {0x03CC, 0x8130CC32}, {0x03CD, 0x8130CC33}, {0x03CE, 0x8130CC34}, {0x03CF, 0x8130CC35}, {0x03D0, 0x8130CC36}, {0x03D1, 0x8130CC37}, {0x03D2, 0x8130CC38}, {0x03D3, 0x8130CC39}, {0x03D4, 0x8130CD30}, {0x03D5, 0x8130CD31}, {0x03D6, 0x8130CD32}, {0x03D7, 0x8130CD33}, {0x03D8, 0x8130CD34}, {0x03D9, 0x8130CD35}, {0x03DA, 0x8130CD36}, {0x03DB, 0x8130CD37}, {0x03DC, 0x8130CD38}, {0x03DD, 0x8130CD39}, {0x03DE, 0x8130CE30}, {0x03DF, 0x8130CE31}, {0x03E0, 0x8130CE32}, {0x03E1, 0x8130CE33}, {0x03E2, 0x8130CE34}, {0x03E3, 0x8130CE35}, {0x03E4, 0x8130CE36}, {0x03E5, 0x8130CE37}, {0x03E6, 0x8130CE38}, {0x03E7, 0x8130CE39}, {0x03E8, 0x8130CF30}, {0x03E9, 0x8130CF31}, {0x03EA, 0x8130CF32}, {0x03EB, 0x8130CF33}, {0x03EC, 0x8130CF34}, {0x03ED, 0x8130CF35}, {0x03EE, 0x8130CF36}, {0x03EF, 0x8130CF37}, {0x03F0, 0x8130CF38}, {0x03F1, 0x8130CF39}, {0x03F2, 0x8130D030}, {0x03F3, 0x8130D031}, {0x03F4, 0x8130D032}, {0x03F5, 0x8130D033}, {0x03F6, 0x8130D034}, {0x03F7, 0x8130D035}, {0x03F8, 0x8130D036}, {0x03F9, 0x8130D037}, {0x03FA, 0x8130D038}, {0x03FB, 0x8130D039}, {0x03FC, 0x8130D130}, {0x03FD, 0x8130D131}, {0x03FE, 0x8130D132}, {0x03FF, 0x8130D133}, {0x0400, 0x8130D134}, {0x0402, 0x8130D135}, {0x0403, 0x8130D136}, {0x0404, 0x8130D137}, {0x0405, 0x8130D138}, {0x0406, 0x8130D139}, {0x0407, 0x8130D230}, {0x0408, 0x8130D231}, {0x0409, 0x8130D232}, {0x040A, 0x8130D233}, {0x040B, 0x8130D234}, {0x040C, 0x8130D235}, {0x040D, 0x8130D236}, {0x040E, 0x8130D237}, {0x040F, 0x8130D238}, {0x0450, 0x8130D239}, {0x2011, 0x8136A532}, {0x2012, 0x8136A533}, {0x2017, 0x8136A534}, {0x201A, 0x8136A535}, {0x201B, 0x8136A536}, {0x201E, 0x8136A537}, {0x201F, 0x8136A538}, {0x2020, 0x8136A539}, {0x2021, 0x8136A630}, {0x2022, 0x8136A631}, {0x2023, 0x8136A632}, {0x2024, 0x8136A633}, {0x2027, 0x8136A634}, {0x2028, 0x8136A635}, {0x2029, 0x8136A636}, {0x202A, 0x8136A637}, {0x202B, 0x8136A638}, {0x202C, 0x8136A639}, {0x202D, 0x8136A730}, {0x202E, 0x8136A731}, {0x202F, 0x8136A732}, {0x2031, 0x8136A733}, {0x2034, 0x8136A734}, {0x2036, 0x8136A735}, {0x2037, 0x8136A736}, {0x2038, 0x8136A737}, {0x2039, 0x8136A738}, {0x203A, 0x8136A739}, {0x203C, 0x8136A830}, {0x203D, 0x8136A831}, {0x203E, 0x8136A832}, {0x203F, 0x8136A833}, {0x2040, 0x8136A834}, {0x2041, 0x8136A835}, {0x2042, 0x8136A836}, {0x2043, 0x8136A837}, {0x2044, 0x8136A838}, {0x2045, 0x8136A839}, {0x2046, 0x8136A930}, {0x2047, 0x8136A931}, {0x2048, 0x8136A932}, {0x2049, 0x8136A933}, {0x204A, 0x8136A934}, {0x204B, 0x8136A935}, {0x204C, 0x8136A936}, {0x204D, 0x8136A937}, {0x204E, 0x8136A938}, {0x204F, 0x8136A939}, {0x2050, 0x8136AA30}, {0x2051, 0x8136AA31}, {0x2052, 0x8136AA32}, {0x2053, 0x8136AA33}, {0x2054, 0x8136AA34}, {0x2055, 0x8136AA35}, {0x2056, 0x8136AA36}, {0x2057, 0x8136AA37}, {0x2058, 0x8136AA38}, {0x2059, 0x8136AA39}, {0x205A, 0x8136AB30}, {0x205B, 0x8136AB31}, {0x205C, 0x8136AB32}, {0x205D, 0x8136AB33}, {0x205E, 0x8136AB34}, {0x205F, 0x8136AB35}, {0x2060, 0x8136AB36}, {0x2061, 0x8136AB37}, {0x2062, 0x8136AB38}, {0x2063, 0x8136AB39}, {0x2064, 0x8136AC30}, {0x2065, 0x8136AC31}, {0x2066, 0x8136AC32}, {0x2067, 0x8136AC33}, {0x2068, 0x8136AC34}, {0x2069, 0x8136AC35}, {0x206A, 0x8136AC36}, {0x206B, 0x8136AC37}, {0x206C, 0x8136AC38}, {0x206D, 0x8136AC39}, {0x206E, 0x8136AD30}, {0x206F, 0x8136AD31}, {0x2070, 0x8136AD32}, {0x2071, 0x8136AD33}, {0x2072, 0x8136AD34}, {0x2073, 0x8136AD35}, {0x2074, 0x8136AD36}, {0x2075, 0x8136AD37}, {0x2076, 0x8136AD38}, {0x2077, 0x8136AD39}, {0x2078, 0x8136AE30}, {0x2079, 0x8136AE31}, {0x207A, 0x8136AE32}, {0x207B, 0x8136AE33}, {0x207C, 0x8136AE34}, {0x207D, 0x8136AE35}, {0x207E, 0x8136AE36}, {0x207F, 0x8136AE37}, {0x2080, 0x8136AE38}, {0x2081, 0x8136AE39}, {0x2082, 0x8136AF30}, {0x2083, 0x8136AF31}, {0x2084, 0x8136AF32}, {0x2085, 0x8136AF33}, {0x2086, 0x8136AF34}, {0x2087, 0x8136AF35}, {0x2088, 0x8136AF36}, {0x2089, 0x8136AF37}, {0x208A, 0x8136AF38}, {0x208B, 0x8136AF39}, {0x208C, 0x8136B030}, {0x208D, 0x8136B031}, {0x208E, 0x8136B032}, {0x208F, 0x8136B033}, {0x2090, 0x8136B034}, {0x2091, 0x8136B035}, {0x2092, 0x8136B036}, {0x2093, 0x8136B037}, {0x2094, 0x8136B038}, {0x2095, 0x8136B039}, {0x2096, 0x8136B130}, {0x2097, 0x8136B131}, {0x2098, 0x8136B132}, {0x2099, 0x8136B133}, {0x209A, 0x8136B134}, {0x209B, 0x8136B135}, {0x209C, 0x8136B136}, {0x209D, 0x8136B137}, {0x209E, 0x8136B138}, {0x209F, 0x8136B139}, {0x20A0, 0x8136B230}, {0x20A1, 0x8136B231}, {0x20A2, 0x8136B232}, {0x20A3, 0x8136B233}, {0x20A4, 0x8136B234}, {0x20A5, 0x8136B235}, {0x20A6, 0x8136B236}, {0x20A7, 0x8136B237}, {0x20A8, 0x8136B238}, {0x20A9, 0x8136B239}, {0x20AA, 0x8136B330}, {0x20AB, 0x8136B331}, {0x20AD, 0x8136B332}, {0x20AE, 0x8136B333}, {0x20AF, 0x8136B334}, {0x20B0, 0x8136B335}, {0x20B1, 0x8136B336}, {0x20B2, 0x8136B337}, {0x20B3, 0x8136B338}, {0x20B4, 0x8136B339}, {0x20B5, 0x8136B430}, {0x20B6, 0x8136B431}, {0x20B7, 0x8136B432}, {0x20B8, 0x8136B433}, {0x20B9, 0x8136B434}, {0x20BA, 0x8136B435}, {0x20BB, 0x8136B436}, {0x20BC, 0x8136B437}, {0x20BD, 0x8136B438}, {0x20BE, 0x8136B439}, {0x20BF, 0x8136B530}, {0x20C0, 0x8136B531}, {0x20C1, 0x8136B532}, {0x20C2, 0x8136B533}, {0x20C3, 0x8136B534}, {0x20C4, 0x8136B535}, {0x20C5, 0x8136B536}, {0x20C6, 0x8136B537}, {0x20C7, 0x8136B538}, {0x20C8, 0x8136B539}, {0x20C9, 0x8136B630}, {0x20CA, 0x8136B631}, {0x20CB, 0x8136B632}, {0x20CC, 0x8136B633}, {0x20CD, 0x8136B634}, {0x20CE, 0x8136B635}, {0x20CF, 0x8136B636}, {0x20D0, 0x8136B637}, {0x20D1, 0x8136B638}, {0x20D2, 0x8136B639}, {0x20D3, 0x8136B730}, {0x20D4, 0x8136B731}, {0x20D5, 0x8136B732}, {0x20D6, 0x8136B733}, {0x20D7, 0x8136B734}, {0x20D8, 0x8136B735}, {0x20D9, 0x8136B736}, {0x20DA, 0x8136B737}, {0x20DB, 0x8136B738}, {0x20DC, 0x8136B739}, {0x20DD, 0x8136B830}, {0x20DE, 0x8136B831}, {0x20DF, 0x8136B832}, {0x20E0, 0x8136B833}, {0x20E1, 0x8136B834}, {0x20E2, 0x8136B835}, {0x20E3, 0x8136B836}, {0x20E4, 0x8136B837}, {0x20E5, 0x8136B838}, {0x20E6, 0x8136B839}, {0x20E7, 0x8136B930}, {0x20E8, 0x8136B931}, {0x20E9, 0x8136B932}, {0x20EA, 0x8136B933}, {0x20EB, 0x8136B934}, {0x20EC, 0x8136B935}, {0x20ED, 0x8136B936}, {0x20EE, 0x8136B937}, {0x20EF, 0x8136B938}, {0x20F0, 0x8136B939}, {0x20F1, 0x8136BA30}, {0x20F2, 0x8136BA31}, {0x20F3, 0x8136BA32}, {0x20F4, 0x8136BA33}, {0x20F5, 0x8136BA34}, {0x20F6, 0x8136BA35}, {0x20F7, 0x8136BA36}, {0x20F8, 0x8136BA37}, {0x20F9, 0x8136BA38}, {0x20FA, 0x8136BA39}, {0x20FB, 0x8136BB30}, {0x20FC, 0x8136BB31}, {0x20FD, 0x8136BB32}, {0x20FE, 0x8136BB33}, {0x20FF, 0x8136BB34}, {0x2100, 0x8136BB35}, {0x2101, 0x8136BB36}, {0x2102, 0x8136BB37}, {0x2104, 0x8136BB38}, {0x2106, 0x8136BB39}, {0x2107, 0x8136BC30}, {0x2108, 0x8136BC31}, {0x210A, 0x8136BC32}, {0x210B, 0x8136BC33}, {0x210C, 0x8136BC34}, {0x210D, 0x8136BC35}, {0x210E, 0x8136BC36}, {0x210F, 0x8136BC37}, {0x2110, 0x8136BC38}, {0x2111, 0x8136BC39}, {0x2112, 0x8136BD30}, {0x2113, 0x8136BD31}, {0x2114, 0x8136BD32}, {0x2115, 0x8136BD33}, {0x2117, 0x8136BD34}, {0x2118, 0x8136BD35}, {0x2119, 0x8136BD36}, {0x211A, 0x8136BD37}, {0x211B, 0x8136BD38}, {0x211C, 0x8136BD39}, {0x211D, 0x8136BE30}, {0x211E, 0x8136BE31}, {0x211F, 0x8136BE32}, {0x2120, 0x8136BE33}, {0x2122, 0x8136BE34}, {0x2123, 0x8136BE35}, {0x2124, 0x8136BE36}, {0x2125, 0x8136BE37}, {0x2126, 0x8136BE38}, {0x2127, 0x8136BE39}, {0x2128, 0x8136BF30}, {0x2129, 0x8136BF31}, {0x212A, 0x8136BF32}, {0x212B, 0x8136BF33}, {0x212C, 0x8136BF34}, {0x212D, 0x8136BF35}, {0x212E, 0x8136BF36}, {0x212F, 0x8136BF37}, {0x2130, 0x8136BF38}, {0x2131, 0x8136BF39}, {0x2132, 0x8136C030}, {0x2133, 0x8136C031}, {0x2134, 0x8136C032}, {0x2135, 0x8136C033}, {0x2136, 0x8136C034}, {0x2137, 0x8136C035}, {0x2138, 0x8136C036}, {0x2139, 0x8136C037}, {0x213A, 0x8136C038}, {0x213B, 0x8136C039}, {0x213C, 0x8136C130}, {0x213D, 0x8136C131}, {0x213E, 0x8136C132}, {0x213F, 0x8136C133}, {0x2140, 0x8136C134}, {0x2141, 0x8136C135}, {0x2142, 0x8136C136}, {0x2143, 0x8136C137}, {0x2144, 0x8136C138}, {0x2145, 0x8136C139}, {0x2146, 0x8136C230}, {0x2147, 0x8136C231}, {0x2148, 0x8136C232}, {0x2149, 0x8136C233}, {0x214A, 0x8136C234}, {0x214B, 0x8136C235}, {0x214C, 0x8136C236}, {0x214D, 0x8136C237}, {0x214E, 0x8136C238}, {0x214F, 0x8136C239}, {0x2150, 0x8136C330}, {0x2151, 0x8136C331}, {0x2152, 0x8136C332}, {0x2153, 0x8136C333}, {0x2154, 0x8136C334}, {0x2155, 0x8136C335}, {0x2156, 0x8136C336}, {0x2157, 0x8136C337}, {0x2158, 0x8136C338}, {0x2159, 0x8136C339}, {0x215A, 0x8136C430}, {0x215B, 0x8136C431}, {0x215C, 0x8136C432}, {0x215D, 0x8136C433}, {0x215E, 0x8136C434}, {0x215F, 0x8136C435}, {0x216C, 0x8136C436}, {0x216D, 0x8136C437}, {0x216E, 0x8136C438}, {0x216F, 0x8136C439}, {0x217A, 0x8136C530}, {0x217B, 0x8136C531}, {0x217C, 0x8136C532}, {0x217D, 0x8136C533}, {0x217E, 0x8136C534}, {0x217F, 0x8136C535}, {0x2180, 0x8136C536}, {0x2181, 0x8136C537}, {0x2182, 0x8136C538}, {0x2183, 0x8136C539}, {0x2184, 0x8136C630}, {0x2185, 0x8136C631}, {0x2186, 0x8136C632}, {0x2187, 0x8136C633}, {0x2188, 0x8136C634}, {0x2189, 0x8136C635}, {0x218A, 0x8136C636}, {0x218B, 0x8136C637}, {0x218C, 0x8136C638}, {0x218D, 0x8136C639}, {0x218E, 0x8136C730}, {0x218F, 0x8136C731}, {0x2194, 0x8136C732}, {0x2195, 0x8136C733}, {0x219A, 0x8136C734}, {0x219B, 0x8136C735}, {0x219C, 0x8136C736}, {0x219D, 0x8136C737}, {0x219E, 0x8136C738}, {0x219F, 0x8136C739}, {0x21A0, 0x8136C830}, {0x21A1, 0x8136C831}, {0x21A2, 0x8136C832}, {0x21A3, 0x8136C833}, {0x21A4, 0x8136C834}, {0x21A5, 0x8136C835}, {0x21A6, 0x8136C836}, {0x21A7, 0x8136C837}, {0x21A8, 0x8136C838}, {0x21A9, 0x8136C839}, {0x21AA, 0x8136C930}, {0x21AB, 0x8136C931}, {0x21AC, 0x8136C932}, {0x21AD, 0x8136C933}, {0x21AE, 0x8136C934}, {0x21AF, 0x8136C935}, {0x21B0, 0x8136C936}, {0x21B1, 0x8136C937}, {0x21B2, 0x8136C938}, {0x21B3, 0x8136C939}, {0x21B4, 0x8136CA30}, {0x21B5, 0x8136CA31}, {0x21B6, 0x8136CA32}, {0x21B7, 0x8136CA33}, {0x21B8, 0x8136CA34}, {0x21B9, 0x8136CA35}, {0x21BA, 0x8136CA36}, {0x21BB, 0x8136CA37}, {0x21BC, 0x8136CA38}, {0x21BD, 0x8136CA39}, {0x21BE, 0x8136CB30}, {0x21BF, 0x8136CB31}, {0x21C0, 0x8136CB32}, {0x21C1, 0x8136CB33}, {0x21C2, 0x8136CB34}, {0x21C3, 0x8136CB35}, {0x21C4, 0x8136CB36}, {0x21C5, 0x8136CB37}, {0x21C6, 0x8136CB38}, {0x21C7, 0x8136CB39}, {0x21C8, 0x8136CC30}, {0x21C9, 0x8136CC31}, {0x21CA, 0x8136CC32}, {0x21CB, 0x8136CC33}, {0x21CC, 0x8136CC34}, {0x21CD, 0x8136CC35}, {0x21CE, 0x8136CC36}, {0x21CF, 0x8136CC37}, {0x21D0, 0x8136CC38}, {0x21D1, 0x8136CC39}, {0x21D2, 0x8136CD30}, {0x21D3, 0x8136CD31}, {0x21D4, 0x8136CD32}, {0x21D5, 0x8136CD33}, {0x21D6, 0x8136CD34}, {0x21D7, 0x8136CD35}, {0x21D8, 0x8136CD36}, {0x21D9, 0x8136CD37}, {0x21DA, 0x8136CD38}, {0x21DB, 0x8136CD39}, {0x21DC, 0x8136CE30}, {0x21DD, 0x8136CE31}, {0x21DE, 0x8136CE32}, {0x21DF, 0x8136CE33}, {0x21E0, 0x8136CE34}, {0x21E1, 0x8136CE35}, {0x21E2, 0x8136CE36}, {0x21E3, 0x8136CE37}, {0x21E4, 0x8136CE38}, {0x21E5, 0x8136CE39}, {0x21E6, 0x8136CF30}, {0x21E7, 0x8136CF31}, {0x21E8, 0x8136CF32}, {0x21E9, 0x8136CF33}, {0x21EA, 0x8136CF34}, {0x21EB, 0x8136CF35}, {0x21EC, 0x8136CF36}, {0x21ED, 0x8136CF37}, {0x21EE, 0x8136CF38}, {0x21EF, 0x8136CF39}, {0x21F0, 0x8136D030}, {0x21F1, 0x8136D031}, {0x21F2, 0x8136D032}, {0x21F3, 0x8136D033}, {0x21F4, 0x8136D034}, {0x21F5, 0x8136D035}, {0x21F6, 0x8136D036}, {0x21F7, 0x8136D037}, {0x21F8, 0x8136D038}, {0x21F9, 0x8136D039}, {0x21FA, 0x8136D130}, {0x21FB, 0x8136D131}, {0x21FC, 0x8136D132}, {0x21FD, 0x8136D133}, {0x21FE, 0x8136D134}, {0x21FF, 0x8136D135}, {0x2200, 0x8136D136}, {0x2201, 0x8136D137}, {0x2202, 0x8136D138}, {0x2203, 0x8136D139}, {0x2204, 0x8136D230}, {0x2205, 0x8136D231}, {0x2206, 0x8136D232}, {0x2207, 0x8136D233}, {0x2209, 0x8136D234}, {0x220A, 0x8136D235}, {0x220B, 0x8136D236}, {0x220C, 0x8136D237}, {0x220D, 0x8136D238}, {0x220E, 0x8136D239}, {0x2210, 0x8136D330}, {0x2212, 0x8136D331}, {0x2213, 0x8136D332}, {0x2214, 0x8136D333}, {0x2216, 0x8136D334}, {0x2217, 0x8136D335}, {0x2218, 0x8136D336}, {0x2219, 0x8136D337}, {0x221B, 0x8136D338}, {0x221C, 0x8136D339}, {0x2221, 0x8136D430}, {0x2222, 0x8136D431}, {0x2224, 0x8136D432}, {0x2226, 0x8136D433}, {0x222C, 0x8136D434}, {0x222D, 0x8136D435}, {0x222F, 0x8136D436}, {0x2230, 0x8136D437}, {0x2231, 0x8136D438}, {0x2232, 0x8136D439}, {0x2233, 0x8136D530}, {0x2238, 0x8136D531}, {0x2239, 0x8136D532}, {0x223A, 0x8136D533}, {0x223B, 0x8136D534}, {0x223C, 0x8136D535}, {0x223E, 0x8136D536}, {0x223F, 0x8136D537}, {0x2240, 0x8136D538}, {0x2241, 0x8136D539}, {0x2242, 0x8136D630}, {0x2243, 0x8136D631}, {0x2244, 0x8136D632}, {0x2245, 0x8136D633}, {0x2246, 0x8136D634}, {0x2247, 0x8136D635}, {0x2249, 0x8136D636}, {0x224A, 0x8136D637}, {0x224B, 0x8136D638}, {0x224D, 0x8136D639}, {0x224E, 0x8136D730}, {0x224F, 0x8136D731}, {0x2250, 0x8136D732}, {0x2251, 0x8136D733}, {0x2253, 0x8136D734}, {0x2254, 0x8136D735}, {0x2255, 0x8136D736}, {0x2256, 0x8136D737}, {0x2257, 0x8136D738}, {0x2258, 0x8136D739}, {0x2259, 0x8136D830}, {0x225A, 0x8136D831}, {0x225B, 0x8136D832}, {0x225C, 0x8136D833}, {0x225D, 0x8136D834}, {0x225E, 0x8136D835}, {0x225F, 0x8136D836}, {0x2262, 0x8136D837}, {0x2263, 0x8136D838}, {0x2268, 0x8136D839}, {0x2269, 0x8136D930}, {0x226A, 0x8136D931}, {0x226B, 0x8136D932}, {0x226C, 0x8136D933}, {0x226D, 0x8136D934}, {0x2270, 0x8136D935}, {0x2271, 0x8136D936}, {0x2272, 0x8136D937}, {0x2273, 0x8136D938}, {0x2274, 0x8136D939}, {0x2275, 0x8136DA30}, {0x2276, 0x8136DA31}, {0x2277, 0x8136DA32}, {0x2278, 0x8136DA33}, {0x2279, 0x8136DA34}, {0x227A, 0x8136DA35}, {0x227B, 0x8136DA36}, {0x227C, 0x8136DA37}, {0x227D, 0x8136DA38}, {0x227E, 0x8136DA39}, {0x227F, 0x8136DB30}, {0x2280, 0x8136DB31}, {0x2281, 0x8136DB32}, {0x2282, 0x8136DB33}, {0x2283, 0x8136DB34}, {0x2284, 0x8136DB35}, {0x2285, 0x8136DB36}, {0x2286, 0x8136DB37}, {0x2287, 0x8136DB38}, {0x2288, 0x8136DB39}, {0x2289, 0x8136DC30}, {0x228A, 0x8136DC31}, {0x228B, 0x8136DC32}, {0x228C, 0x8136DC33}, {0x228D, 0x8136DC34}, {0x228E, 0x8136DC35}, {0x228F, 0x8136DC36}, {0x2290, 0x8136DC37}, {0x2291, 0x8136DC38}, {0x2292, 0x8136DC39}, {0x2293, 0x8136DD30}, {0x2294, 0x8136DD31}, {0x2296, 0x8136DD32}, {0x2297, 0x8136DD33}, {0x2298, 0x8136DD34}, {0x229A, 0x8136DD35}, {0x229B, 0x8136DD36}, {0x229C, 0x8136DD37}, {0x229D, 0x8136DD38}, {0x229E, 0x8136DD39}, {0x229F, 0x8136DE30}, {0x22A0, 0x8136DE31}, {0x22A1, 0x8136DE32}, {0x22A2, 0x8136DE33}, {0x22A3, 0x8136DE34}, {0x22A4, 0x8136DE35}, {0x22A6, 0x8136DE36}, {0x22A7, 0x8136DE37}, {0x22A8, 0x8136DE38}, {0x22A9, 0x8136DE39}, {0x22AA, 0x8136DF30}, {0x22AB, 0x8136DF31}, {0x22AC, 0x8136DF32}, {0x22AD, 0x8136DF33}, {0x22AE, 0x8136DF34}, {0x22AF, 0x8136DF35}, {0x22B0, 0x8136DF36}, {0x22B1, 0x8136DF37}, {0x22B2, 0x8136DF38}, {0x22B3, 0x8136DF39}, {0x22B4, 0x8136E030}, {0x22B5, 0x8136E031}, {0x22B6, 0x8136E032}, {0x22B7, 0x8136E033}, {0x22B8, 0x8136E034}, {0x22B9, 0x8136E035}, {0x22BA, 0x8136E036}, {0x22BB, 0x8136E037}, {0x22BC, 0x8136E038}, {0x22BD, 0x8136E039}, {0x22BE, 0x8136E130}, {0x22C0, 0x8136E131}, {0x22C1, 0x8136E132}, {0x22C2, 0x8136E133}, {0x22C3, 0x8136E134}, {0x22C4, 0x8136E135}, {0x22C5, 0x8136E136}, {0x22C6, 0x8136E137}, {0x22C7, 0x8136E138}, {0x22C8, 0x8136E139}, {0x22C9, 0x8136E230}, {0x22CA, 0x8136E231}, {0x22CB, 0x8136E232}, {0x22CC, 0x8136E233}, {0x22CD, 0x8136E234}, {0x22CE, 0x8136E235}, {0x22CF, 0x8136E236}, {0x22D0, 0x8136E237}, {0x22D1, 0x8136E238}, {0x22D2, 0x8136E239}, {0x22D3, 0x8136E330}, {0x22D4, 0x8136E331}, {0x22D5, 0x8136E332}, {0x22D6, 0x8136E333}, {0x22D7, 0x8136E334}, {0x22D8, 0x8136E335}, {0x22D9, 0x8136E336}, {0x22DA, 0x8136E337}, {0x22DB, 0x8136E338}, {0x22DC, 0x8136E339}, {0x22DD, 0x8136E430}, {0x22DE, 0x8136E431}, {0x22DF, 0x8136E432}, {0x22E0, 0x8136E433}, {0x22E1, 0x8136E434}, {0x22E2, 0x8136E435}, {0x22E3, 0x8136E436}, {0x22E4, 0x8136E437}, {0x22E5, 0x8136E438}, {0x22E6, 0x8136E439}, {0x22E7, 0x8136E530}, {0x22E8, 0x8136E531}, {0x22E9, 0x8136E532}, {0x22EA, 0x8136E533}, {0x22EB, 0x8136E534}, {0x22EC, 0x8136E535}, {0x22ED, 0x8136E536}, {0x22EE, 0x8136E537}, {0x22EF, 0x8136E538}, {0x22F0, 0x8136E539}, {0x22F1, 0x8136E630}, {0x22F2, 0x8136E631}, {0x22F3, 0x8136E632}, {0x22F4, 0x8136E633}, {0x22F5, 0x8136E634}, {0x22F6, 0x8136E635}, {0x22F7, 0x8136E636}, {0x22F8, 0x8136E637}, {0x22F9, 0x8136E638}, {0x22FA, 0x8136E639}, {0x22FB, 0x8136E730}, {0x22FC, 0x8136E731}, {0x22FD, 0x8136E732}, {0x22FE, 0x8136E733}, {0x22FF, 0x8136E734}, {0x2300, 0x8136E735}, {0x2301, 0x8136E736}, {0x2302, 0x8136E737}, {0x2303, 0x8136E738}, {0x2304, 0x8136E739}, {0x2305, 0x8136E830}, {0x2306, 0x8136E831}, {0x2307, 0x8136E832}, {0x2308, 0x8136E833}, {0x2309, 0x8136E834}, {0x230A, 0x8136E835}, {0x230B, 0x8136E836}, {0x230C, 0x8136E837}, {0x230D, 0x8136E838}, {0x230E, 0x8136E839}, {0x230F, 0x8136E930}, {0x2310, 0x8136E931}, {0x2311, 0x8136E932}, {0x2313, 0x8136E933}, {0x2314, 0x8136E934}, {0x2315, 0x8136E935}, {0x2316, 0x8136E936}, {0x2317, 0x8136E937}, {0x2318, 0x8136E938}, {0x2319, 0x8136E939}, {0x231A, 0x8136EA30}, {0x231B, 0x8136EA31}, {0x231C, 0x8136EA32}, {0x231D, 0x8136EA33}, {0x231E, 0x8136EA34}, {0x231F, 0x8136EA35}, {0x2320, 0x8136EA36}, {0x2321, 0x8136EA37}, {0x2322, 0x8136EA38}, {0x2323, 0x8136EA39}, {0x2324, 0x8136EB30}, {0x2325, 0x8136EB31}, {0x2326, 0x8136EB32}, {0x2327, 0x8136EB33}, {0x2328, 0x8136EB34}, {0x2329, 0x8136EB35}, {0x232A, 0x8136EB36}, {0x232B, 0x8136EB37}, {0x232C, 0x8136EB38}, {0x232D, 0x8136EB39}, {0x232E, 0x8136EC30}, {0x232F, 0x8136EC31}, {0x2330, 0x8136EC32}, {0x2331, 0x8136EC33}, {0x2332, 0x8136EC34}, {0x2333, 0x8136EC35}, {0x2334, 0x8136EC36}, {0x2335, 0x8136EC37}, {0x2336, 0x8136EC38}, {0x2337, 0x8136EC39}, {0x2338, 0x8136ED30}, {0x2339, 0x8136ED31}, {0x233A, 0x8136ED32}, {0x233B, 0x8136ED33}, {0x233C, 0x8136ED34}, {0x233D, 0x8136ED35}, {0x233E, 0x8136ED36}, {0x233F, 0x8136ED37}, {0x2340, 0x8136ED38}, {0x2341, 0x8136ED39}, {0x2342, 0x8136EE30}, {0x2343, 0x8136EE31}, {0x2344, 0x8136EE32}, {0x2345, 0x8136EE33}, {0x2346, 0x8136EE34}, {0x2347, 0x8136EE35}, {0x2348, 0x8136EE36}, {0x2349, 0x8136EE37}, {0x234A, 0x8136EE38}, {0x234B, 0x8136EE39}, {0x234C, 0x8136EF30}, {0x234D, 0x8136EF31}, {0x234E, 0x8136EF32}, {0x234F, 0x8136EF33}, {0x2350, 0x8136EF34}, {0x2351, 0x8136EF35}, {0x2352, 0x8136EF36}, {0x2353, 0x8136EF37}, {0x2354, 0x8136EF38}, {0x2355, 0x8136EF39}, {0x2356, 0x8136F030}, {0x2357, 0x8136F031}, {0x2358, 0x8136F032}, {0x2359, 0x8136F033}, {0x235A, 0x8136F034}, {0x235B, 0x8136F035}, {0x235C, 0x8136F036}, {0x235D, 0x8136F037}, {0x235E, 0x8136F038}, {0x235F, 0x8136F039}, {0x2360, 0x8136F130}, {0x2361, 0x8136F131}, {0x2362, 0x8136F132}, {0x2363, 0x8136F133}, {0x2364, 0x8136F134}, {0x2365, 0x8136F135}, {0x2366, 0x8136F136}, {0x2367, 0x8136F137}, {0x2368, 0x8136F138}, {0x2369, 0x8136F139}, {0x236A, 0x8136F230}, {0x236B, 0x8136F231}, {0x236C, 0x8136F232}, {0x236D, 0x8136F233}, {0x236E, 0x8136F234}, {0x236F, 0x8136F235}, {0x2370, 0x8136F236}, {0x2371, 0x8136F237}, {0x2372, 0x8136F238}, {0x2373, 0x8136F239}, {0x2374, 0x8136F330}, {0x2375, 0x8136F331}, {0x2376, 0x8136F332}, {0x2377, 0x8136F333}, {0x2378, 0x8136F334}, {0x2379, 0x8136F335}, {0x237A, 0x8136F336}, {0x237B, 0x8136F337}, {0x237C, 0x8136F338}, {0x237D, 0x8136F339}, {0x237E, 0x8136F430}, {0x237F, 0x8136F431}, {0x2380, 0x8136F432}, {0x2381, 0x8136F433}, {0x2382, 0x8136F434}, {0x2383, 0x8136F435}, {0x2384, 0x8136F436}, {0x2385, 0x8136F437}, {0x2386, 0x8136F438}, {0x2387, 0x8136F439}, {0x2388, 0x8136F530}, {0x2389, 0x8136F531}, {0x238A, 0x8136F532}, {0x238B, 0x8136F533}, {0x238C, 0x8136F534}, {0x238D, 0x8136F535}, {0x238E, 0x8136F536}, {0x238F, 0x8136F537}, {0x2390, 0x8136F538}, {0x2391, 0x8136F539}, {0x2392, 0x8136F630}, {0x2393, 0x8136F631}, {0x2394, 0x8136F632}, {0x2395, 0x8136F633}, {0x2396, 0x8136F634}, {0x2397, 0x8136F635}, {0x2398, 0x8136F636}, {0x2399, 0x8136F637}, {0x239A, 0x8136F638}, {0x239B, 0x8136F639}, {0x239C, 0x8136F730}, {0x239D, 0x8136F731}, {0x239E, 0x8136F732}, {0x239F, 0x8136F733}, {0x23A0, 0x8136F734}, {0x23A1, 0x8136F735}, {0x23A2, 0x8136F736}, {0x23A3, 0x8136F737}, {0x23A4, 0x8136F738}, {0x23A5, 0x8136F739}, {0x23A6, 0x8136F830}, {0x23A7, 0x8136F831}, {0x23A8, 0x8136F832}, {0x23A9, 0x8136F833}, {0x23AA, 0x8136F834}, {0x23AB, 0x8136F835}, {0x23AC, 0x8136F836}, {0x23AD, 0x8136F837}, {0x23AE, 0x8136F838}, {0x23AF, 0x8136F839}, {0x23B0, 0x8136F930}, {0x23B1, 0x8136F931}, {0x23B2, 0x8136F932}, {0x23B3, 0x8136F933}, {0x23B4, 0x8136F934}, {0x23B5, 0x8136F935}, {0x23B6, 0x8136F936}, {0x23B7, 0x8136F937}, {0x23B8, 0x8136F938}, {0x23B9, 0x8136F939}, {0x23BA, 0x8136FA30}, {0x23BB, 0x8136FA31}, {0x23BC, 0x8136FA32}, {0x23BD, 0x8136FA33}, {0x23BE, 0x8136FA34}, {0x23BF, 0x8136FA35}, {0x23C0, 0x8136FA36}, {0x23C1, 0x8136FA37}, {0x23C2, 0x8136FA38}, {0x23C3, 0x8136FA39}, {0x23C4, 0x8136FB30}, {0x23C5, 0x8136FB31}, {0x23C6, 0x8136FB32}, {0x23C7, 0x8136FB33}, {0x23C8, 0x8136FB34}, {0x23C9, 0x8136FB35}, {0x23CA, 0x8136FB36}, {0x23CB, 0x8136FB37}, {0x23CC, 0x8136FB38}, {0x23CD, 0x8136FB39}, {0x23CE, 0x8136FC30}, {0x23CF, 0x8136FC31}, {0x23D0, 0x8136FC32}, {0x23D1, 0x8136FC33}, {0x23D2, 0x8136FC34}, {0x23D3, 0x8136FC35}, {0x23D4, 0x8136FC36}, {0x23D5, 0x8136FC37}, {0x23D6, 0x8136FC38}, {0x23D7, 0x8136FC39}, {0x23D8, 0x8136FD30}, {0x23D9, 0x8136FD31}, {0x23DA, 0x8136FD32}, {0x23DB, 0x8136FD33}, {0x23DC, 0x8136FD34}, {0x23DD, 0x8136FD35}, {0x23DE, 0x8136FD36}, {0x23DF, 0x8136FD37}, {0x23E0, 0x8136FD38}, {0x23E1, 0x8136FD39}, {0x23E2, 0x8136FE30}, {0x23E3, 0x8136FE31}, {0x23E4, 0x8136FE32}, {0x23E5, 0x8136FE33}, {0x23E6, 0x8136FE34}, {0x23E7, 0x8136FE35}, {0x23E8, 0x8136FE36}, {0x23E9, 0x8136FE37}, {0x23EA, 0x8136FE38}, {0x23EB, 0x8136FE39}, {0x23EC, 0x81378130}, {0x23ED, 0x81378131}, {0x23EE, 0x81378132}, {0x23EF, 0x81378133}, {0x23F0, 0x81378134}, {0x23F1, 0x81378135}, {0x23F2, 0x81378136}, {0x23F3, 0x81378137}, {0x23F4, 0x81378138}, {0x23F5, 0x81378139}, {0x23F6, 0x81378230}, {0x23F7, 0x81378231}, {0x23F8, 0x81378232}, {0x23F9, 0x81378233}, {0x23FA, 0x81378234}, {0x23FB, 0x81378235}, {0x23FC, 0x81378236}, {0x23FD, 0x81378237}, {0x23FE, 0x81378238}, {0x23FF, 0x81378239}, {0x2400, 0x81378330}, {0x2401, 0x81378331}, {0x2402, 0x81378332}, {0x2403, 0x81378333}, {0x2404, 0x81378334}, {0x2405, 0x81378335}, {0x2406, 0x81378336}, {0x2407, 0x81378337}, {0x2408, 0x81378338}, {0x2409, 0x81378339}, {0x240A, 0x81378430}, {0x240B, 0x81378431}, {0x240C, 0x81378432}, {0x240D, 0x81378433}, {0x240E, 0x81378434}, {0x240F, 0x81378435}, {0x2410, 0x81378436}, {0x2411, 0x81378437}, {0x2412, 0x81378438}, {0x2413, 0x81378439}, {0x2414, 0x81378530}, {0x2415, 0x81378531}, {0x2416, 0x81378532}, {0x2417, 0x81378533}, {0x2418, 0x81378534}, {0x2419, 0x81378535}, {0x241A, 0x81378536}, {0x241B, 0x81378537}, {0x241C, 0x81378538}, {0x241D, 0x81378539}, {0x241E, 0x81378630}, {0x241F, 0x81378631}, {0x2420, 0x81378632}, {0x2421, 0x81378633}, {0x2422, 0x81378634}, {0x2423, 0x81378635}, {0x2424, 0x81378636}, {0x2425, 0x81378637}, {0x2426, 0x81378638}, {0x2427, 0x81378639}, {0x2428, 0x81378730}, {0x2429, 0x81378731}, {0x242A, 0x81378732}, {0x242B, 0x81378733}, {0x242C, 0x81378734}, {0x242D, 0x81378735}, {0x242E, 0x81378736}, {0x242F, 0x81378737}, {0x2430, 0x81378738}, {0x2431, 0x81378739}, {0x2432, 0x81378830}, {0x2433, 0x81378831}, {0x2434, 0x81378832}, {0x2435, 0x81378833}, {0x2436, 0x81378834}, {0x2437, 0x81378835}, {0x2438, 0x81378836}, {0x2439, 0x81378837}, {0x243A, 0x81378838}, {0x243B, 0x81378839}, {0x243C, 0x81378930}, {0x243D, 0x81378931}, {0x243E, 0x81378932}, {0x243F, 0x81378933}, {0x2440, 0x81378934}, {0x2441, 0x81378935}, {0x2442, 0x81378936}, {0x2443, 0x81378937}, {0x2444, 0x81378938}, {0x2445, 0x81378939}, {0x2446, 0x81378A30}, {0x2447, 0x81378A31}, {0x2448, 0x81378A32}, {0x2449, 0x81378A33}, {0x244A, 0x81378A34}, {0x244B, 0x81378A35}, {0x244C, 0x81378A36}, {0x244D, 0x81378A37}, {0x244E, 0x81378A38}, {0x244F, 0x81378A39}, {0x2450, 0x81378B30}, {0x2451, 0x81378B31}, {0x2452, 0x81378B32}, {0x2453, 0x81378B33}, {0x2454, 0x81378B34}, {0x2455, 0x81378B35}, {0x2456, 0x81378B36}, {0x2457, 0x81378B37}, {0x2458, 0x81378B38}, {0x2459, 0x81378B39}, {0x245A, 0x81378C30}, {0x245B, 0x81378C31}, {0x245C, 0x81378C32}, {0x245D, 0x81378C33}, {0x245E, 0x81378C34}, {0x245F, 0x81378C35}, {0x246A, 0x81378C36}, {0x246B, 0x81378C37}, {0x246C, 0x81378C38}, {0x246D, 0x81378C39}, {0x246E, 0x81378D30}, {0x246F, 0x81378D31}, {0x2470, 0x81378D32}, {0x2471, 0x81378D33}, {0x2472, 0x81378D34}, {0x2473, 0x81378D35}, {0x249C, 0x81378D36}, {0x249D, 0x81378D37}, {0x249E, 0x81378D38}, {0x249F, 0x81378D39}, {0x24A0, 0x81378E30}, {0x24A1, 0x81378E31}, {0x24A2, 0x81378E32}, {0x24A3, 0x81378E33}, {0x24A4, 0x81378E34}, {0x24A5, 0x81378E35}, {0x24A6, 0x81378E36}, {0x24A7, 0x81378E37}, {0x24A8, 0x81378E38}, {0x24A9, 0x81378E39}, {0x24AA, 0x81378F30}, {0x24AB, 0x81378F31}, {0x24AC, 0x81378F32}, {0x24AD, 0x81378F33}, {0x24AE, 0x81378F34}, {0x24AF, 0x81378F35}, {0x24B0, 0x81378F36}, {0x24B1, 0x81378F37}, {0x24B2, 0x81378F38}, {0x24B3, 0x81378F39}, {0x24B4, 0x81379030}, {0x24B5, 0x81379031}, {0x24B6, 0x81379032}, {0x24B7, 0x81379033}, {0x24B8, 0x81379034}, {0x24B9, 0x81379035}, {0x24BA, 0x81379036}, {0x24BB, 0x81379037}, {0x24BC, 0x81379038}, {0x24BD, 0x81379039}, {0x24BE, 0x81379130}, {0x24BF, 0x81379131}, {0x24C0, 0x81379132}, {0x24C1, 0x81379133}, {0x24C2, 0x81379134}, {0x24C3, 0x81379135}, {0x24C4, 0x81379136}, {0x24C5, 0x81379137}, {0x24C6, 0x81379138}, {0x24C7, 0x81379139}, {0x24C8, 0x81379230}, {0x24C9, 0x81379231}, {0x24CA, 0x81379232}, {0x24CB, 0x81379233}, {0x24CC, 0x81379234}, {0x24CD, 0x81379235}, {0x24CE, 0x81379236}, {0x24CF, 0x81379237}, {0x24D0, 0x81379238}, {0x24D1, 0x81379239}, {0x24D2, 0x81379330}, {0x24D3, 0x81379331}, {0x24D4, 0x81379332}, {0x24D5, 0x81379333}, {0x24D6, 0x81379334}, {0x24D7, 0x81379335}, {0x24D8, 0x81379336}, {0x24D9, 0x81379337}, {0x24DA, 0x81379338}, {0x24DB, 0x81379339}, {0x24DC, 0x81379430}, {0x24DD, 0x81379431}, {0x24DE, 0x81379432}, {0x24DF, 0x81379433}, {0x24E0, 0x81379434}, {0x24E1, 0x81379435}, {0x24E2, 0x81379436}, {0x24E3, 0x81379437}, {0x24E4, 0x81379438}, {0x24E5, 0x81379439}, {0x24E6, 0x81379530}, {0x24E7, 0x81379531}, {0x24E8, 0x81379532}, {0x24E9, 0x81379533}, {0x24EA, 0x81379534}, {0x24EB, 0x81379535}, {0x24EC, 0x81379536}, {0x24ED, 0x81379537}, {0x24EE, 0x81379538}, {0x24EF, 0x81379539}, {0x24F0, 0x81379630}, {0x24F1, 0x81379631}, {0x24F2, 0x81379632}, {0x24F3, 0x81379633}, {0x24F4, 0x81379634}, {0x24F5, 0x81379635}, {0x24F6, 0x81379636}, {0x24F7, 0x81379637}, {0x24F8, 0x81379638}, {0x24F9, 0x81379639}, {0x24FA, 0x81379730}, {0x24FB, 0x81379731}, {0x24FC, 0x81379732}, {0x24FD, 0x81379733}, {0x24FE, 0x81379734}, {0x24FF, 0x81379735}, {0x254C, 0x81379736}, {0x254D, 0x81379737}, {0x254E, 0x81379738}, {0x254F, 0x81379739}, {0x2574, 0x81379830}, {0x2575, 0x81379831}, {0x2576, 0x81379832}, {0x2577, 0x81379833}, {0x2578, 0x81379834}, {0x2579, 0x81379835}, {0x257A, 0x81379836}, {0x257B, 0x81379837}, {0x257C, 0x81379838}, {0x257D, 0x81379839}, {0x257E, 0x81379930}, {0x257F, 0x81379931}, {0x2580, 0x81379932}, {0x2590, 0x81379933}, {0x2591, 0x81379934}, {0x2592, 0x81379935}, {0x2596, 0x81379936}, {0x2597, 0x81379937}, {0x2598, 0x81379938}, {0x2599, 0x81379939}, {0x259A, 0x81379A30}, {0x259B, 0x81379A31}, {0x259C, 0x81379A32}, {0x259D, 0x81379A33}, {0x259E, 0x81379A34}, {0x259F, 0x81379A35}, {0x25A2, 0x81379A36}, {0x25A3, 0x81379A37}, {0x25A4, 0x81379A38}, {0x25A5, 0x81379A39}, {0x25A6, 0x81379B30}, {0x25A7, 0x81379B31}, {0x25A8, 0x81379B32}, {0x25A9, 0x81379B33}, {0x25AA, 0x81379B34}, {0x25AB, 0x81379B35}, {0x25AC, 0x81379B36}, {0x25AD, 0x81379B37}, {0x25AE, 0x81379B38}, {0x25AF, 0x81379B39}, {0x25B0, 0x81379C30}, {0x25B1, 0x81379C31}, {0x25B4, 0x81379C32}, {0x25B5, 0x81379C33}, {0x25B6, 0x81379C34}, {0x25B7, 0x81379C35}, {0x25B8, 0x81379C36}, {0x25B9, 0x81379C37}, {0x25BA, 0x81379C38}, {0x25BB, 0x81379C39}, {0x25BE, 0x81379D30}, {0x25BF, 0x81379D31}, {0x25C0, 0x81379D32}, {0x25C1, 0x81379D33}, {0x25C2, 0x81379D34}, {0x25C3, 0x81379D35}, {0x25C4, 0x81379D36}, {0x25C5, 0x81379D37}, {0x25C8, 0x81379D38}, {0x25C9, 0x81379D39}, {0x25CA, 0x81379E30}, {0x25CC, 0x81379E31}, {0x25CD, 0x81379E32}, {0x25D0, 0x81379E33}, {0x25D1, 0x81379E34}, {0x25D2, 0x81379E35}, {0x25D3, 0x81379E36}, {0x25D4, 0x81379E37}, {0x25D5, 0x81379E38}, {0x25D6, 0x81379E39}, {0x25D7, 0x81379F30}, {0x25D8, 0x81379F31}, {0x25D9, 0x81379F32}, {0x25DA, 0x81379F33}, {0x25DB, 0x81379F34}, {0x25DC, 0x81379F35}, {0x25DD, 0x81379F36}, {0x25DE, 0x81379F37}, {0x25DF, 0x81379F38}, {0x25E0, 0x81379F39}, {0x25E1, 0x8137A030}, {0x25E6, 0x8137A031}, {0x25E7, 0x8137A032}, {0x25E8, 0x8137A033}, {0x25E9, 0x8137A034}, {0x25EA, 0x8137A035}, {0x25EB, 0x8137A036}, {0x25EC, 0x8137A037}, {0x25ED, 0x8137A038}, {0x25EE, 0x8137A039}, {0x25EF, 0x8137A130}, {0x25F0, 0x8137A131}, {0x25F1, 0x8137A132}, {0x25F2, 0x8137A133}, {0x25F3, 0x8137A134}, {0x25F4, 0x8137A135}, {0x25F5, 0x8137A136}, {0x25F6, 0x8137A137}, {0x25F7, 0x8137A138}, {0x25F8, 0x8137A139}, {0x25F9, 0x8137A230}, {0x25FA, 0x8137A231}, {0x25FB, 0x8137A232}, {0x25FC, 0x8137A233}, {0x25FD, 0x8137A234}, {0x25FE, 0x8137A235}, {0x25FF, 0x8137A236}, {0x2600, 0x8137A237}, {0x2601, 0x8137A238}, {0x2602, 0x8137A239}, {0x2603, 0x8137A330}, {0x2604, 0x8137A331}, {0x2607, 0x8137A332}, {0x2608, 0x8137A333}, {0x260A, 0x8137A334}, {0x260B, 0x8137A335}, {0x260C, 0x8137A336}, {0x260D, 0x8137A337}, {0x260E, 0x8137A338}, {0x260F, 0x8137A339}, {0x2610, 0x8137A430}, {0x2611, 0x8137A431}, {0x2612, 0x8137A432}, {0x2613, 0x8137A433}, {0x2614, 0x8137A434}, {0x2615, 0x8137A435}, {0x2616, 0x8137A436}, {0x2617, 0x8137A437}, {0x2618, 0x8137A438}, {0x2619, 0x8137A439}, {0x261A, 0x8137A530}, {0x261B, 0x8137A531}, {0x261C, 0x8137A532}, {0x261D, 0x8137A533}, {0x261E, 0x8137A534}, {0x261F, 0x8137A535}, {0x2620, 0x8137A536}, {0x2621, 0x8137A537}, {0x2622, 0x8137A538}, {0x2623, 0x8137A539}, {0x2624, 0x8137A630}, {0x2625, 0x8137A631}, {0x2626, 0x8137A632}, {0x2627, 0x8137A633}, {0x2628, 0x8137A634}, {0x2629, 0x8137A635}, {0x262A, 0x8137A636}, {0x262B, 0x8137A637}, {0x262C, 0x8137A638}, {0x262D, 0x8137A639}, {0x262E, 0x8137A730}, {0x262F, 0x8137A731}, {0x2630, 0x8137A732}, {0x2631, 0x8137A733}, {0x2632, 0x8137A734}, {0x2633, 0x8137A735}, {0x2634, 0x8137A736}, {0x2635, 0x8137A737}, {0x2636, 0x8137A738}, {0x2637, 0x8137A739}, {0x2638, 0x8137A830}, {0x2639, 0x8137A831}, {0x263A, 0x8137A832}, {0x263B, 0x8137A833}, {0x263C, 0x8137A834}, {0x263D, 0x8137A835}, {0x263E, 0x8137A836}, {0x263F, 0x8137A837}, {0x2641, 0x8137A838}, {0x2E82, 0x8138FD39}, {0x2E83, 0x8138FE30}, {0x2E85, 0x8138FE31}, {0x2E86, 0x8138FE32}, {0x2E87, 0x8138FE33}, {0x2E89, 0x8138FE34}, {0x2E8A, 0x8138FE35}, {0x2E8D, 0x8138FE36}, {0x2E8E, 0x8138FE37}, {0x2E8F, 0x8138FE38}, {0x2E90, 0x8138FE39}, {0x2E91, 0x81398130}, {0x2E92, 0x81398131}, {0x2E93, 0x81398132}, {0x2E94, 0x81398133}, {0x2E95, 0x81398134}, {0x2E96, 0x81398135}, {0x2E98, 0x81398136}, {0x2E99, 0x81398137}, {0x2E9A, 0x81398138}, {0x2E9B, 0x81398139}, {0x2E9C, 0x81398230}, {0x2E9D, 0x81398231}, {0x2E9E, 0x81398232}, {0x2E9F, 0x81398233}, {0x2EA0, 0x81398234}, {0x2EA1, 0x81398235}, {0x2EA2, 0x81398236}, {0x2EA3, 0x81398237}, {0x2EA4, 0x81398238}, {0x2EA5, 0x81398239}, {0x2EA6, 0x81398330}, {0x2EA8, 0x81398331}, {0x2EA9, 0x81398332}, {0x2EAB, 0x81398333}, {0x2EAC, 0x81398334}, {0x2EAD, 0x81398335}, {0x2EAF, 0x81398336}, {0x2EB0, 0x81398337}, {0x2EB1, 0x81398338}, {0x2EB2, 0x81398339}, {0x2EB4, 0x81398430}, {0x2EB5, 0x81398431}, {0x2EB8, 0x81398432}, {0x2EB9, 0x81398433}, {0x2EBA, 0x81398434}, {0x2EBC, 0x81398435}, {0x2EBD, 0x81398436}, {0x2EBE, 0x81398437}, {0x2EBF, 0x81398438}, {0x2EC0, 0x81398439}, {0x2EC1, 0x81398530}, {0x2EC2, 0x81398531}, {0x2EC3, 0x81398532}, {0x2EC4, 0x81398533}, {0x2EC5, 0x81398534}, {0x2EC6, 0x81398535}, {0x2EC7, 0x81398536}, {0x2EC8, 0x81398537}, {0x2EC9, 0x81398538}, {0x2ECB, 0x81398539}, {0x2ECC, 0x81398630}, {0x2ECD, 0x81398631}, {0x2ECE, 0x81398632}, {0x2ECF, 0x81398633}, {0x2ED0, 0x81398634}, {0x2ED1, 0x81398635}, {0x2ED2, 0x81398636}, {0x2ED3, 0x81398637}, {0x2ED4, 0x81398638}, {0x2ED5, 0x81398639}, {0x2ED6, 0x81398730}, {0x2ED7, 0x81398731}, {0x2ED8, 0x81398732}, {0x2ED9, 0x81398733}, {0x2EDA, 0x81398734}, {0x2EDB, 0x81398735}, {0x2EDC, 0x81398736}, {0x2EDD, 0x81398737}, {0x2EDE, 0x81398738}, {0x2EDF, 0x81398739}, {0x2EE0, 0x81398830}, {0x2EE1, 0x81398831}, {0x2EE2, 0x81398832}, {0x2EE3, 0x81398833}, {0x2EE4, 0x81398834}, {0x2EE5, 0x81398835}, {0x2EE6, 0x81398836}, {0x2EE7, 0x81398837}, {0x2EE8, 0x81398838}, {0x2EE9, 0x81398839}, {0x2EEA, 0x81398930}, {0x2EEB, 0x81398931}, {0x2EEC, 0x81398932}, {0x2EED, 0x81398933}, {0x2EEE, 0x81398934}, {0x2EEF, 0x81398935}, {0x2EF0, 0x81398936}, {0x2EF1, 0x81398937}, {0x2EF2, 0x81398938}, {0x2EF3, 0x81398939}, {0x2EF4, 0x81398A30}, {0x2EF5, 0x81398A31}, {0x2EF6, 0x81398A32}, {0x2EF7, 0x81398A33}, {0x2EF8, 0x81398A34}, {0x2EF9, 0x81398A35}, {0x2EFA, 0x81398A36}, {0x2EFB, 0x81398A37}, {0x2EFC, 0x81398A38}, {0x2EFD, 0x81398A39}, {0x2EFE, 0x81398B30}, {0x2EFF, 0x81398B31}, {0x2F00, 0x81398B32}, {0x2F01, 0x81398B33}, {0x2F02, 0x81398B34}, {0x2F03, 0x81398B35}, {0x2F04, 0x81398B36}, {0x2F05, 0x81398B37}, {0x2F06, 0x81398B38}, {0x2F07, 0x81398B39}, {0x2F08, 0x81398C30}, {0x2F09, 0x81398C31}, {0x2F0A, 0x81398C32}, {0x2F0B, 0x81398C33}, {0x2F0C, 0x81398C34}, {0x2F0D, 0x81398C35}, {0x2F0E, 0x81398C36}, {0x2F0F, 0x81398C37}, {0x2F10, 0x81398C38}, {0x2F11, 0x81398C39}, {0x2F12, 0x81398D30}, {0x2F13, 0x81398D31}, {0x2F14, 0x81398D32}, {0x2F15, 0x81398D33}, {0x2F16, 0x81398D34}, {0x2F17, 0x81398D35}, {0x2F18, 0x81398D36}, {0x2F19, 0x81398D37}, {0x2F1A, 0x81398D38}, {0x2F1B, 0x81398D39}, {0x2F1C, 0x81398E30}, {0x2F1D, 0x81398E31}, {0x2F1E, 0x81398E32}, {0x2F1F, 0x81398E33}, {0x2F20, 0x81398E34}, {0x2F21, 0x81398E35}, {0x2F22, 0x81398E36}, {0x2F23, 0x81398E37}, {0x2F24, 0x81398E38}, {0x2F25, 0x81398E39}, {0x2F26, 0x81398F30}, {0x2F27, 0x81398F31}, {0x2F28, 0x81398F32}, {0x2F29, 0x81398F33}, {0x2F2A, 0x81398F34}, {0x2F2B, 0x81398F35}, {0x2F2C, 0x81398F36}, {0x2F2D, 0x81398F37}, {0x2F2E, 0x81398F38}, {0x2F2F, 0x81398F39}, {0x2F30, 0x81399030}, {0x2F31, 0x81399031}, {0x2F32, 0x81399032}, {0x2F33, 0x81399033}, {0x2F34, 0x81399034}, {0x2F35, 0x81399035}, {0x2F36, 0x81399036}, {0x2F37, 0x81399037}, {0x2F38, 0x81399038}, {0x2F39, 0x81399039}, {0x2F3A, 0x81399130}, {0x2F3B, 0x81399131}, {0x2F3C, 0x81399132}, {0x2F3D, 0x81399133}, {0x2F3E, 0x81399134}, {0x2F3F, 0x81399135}, {0x2F40, 0x81399136}, {0x2F41, 0x81399137}, {0x2F42, 0x81399138}, {0x2F43, 0x81399139}, {0x2F44, 0x81399230}, {0x2F45, 0x81399231}, {0x2F46, 0x81399232}, {0x2F47, 0x81399233}, {0x2F48, 0x81399234}, {0x2F49, 0x81399235}, {0x2F4A, 0x81399236}, {0x2F4B, 0x81399237}, {0x2F4C, 0x81399238}, {0x2F4D, 0x81399239}, {0x2F4E, 0x81399330}, {0x2F4F, 0x81399331}, {0x2F50, 0x81399332}, {0x2F51, 0x81399333}, {0x2F52, 0x81399334}, {0x2F53, 0x81399335}, {0x2F54, 0x81399336}, {0x2F55, 0x81399337}, {0x2F56, 0x81399338}, {0x2F57, 0x81399339}, {0x2F58, 0x81399430}, {0x2F59, 0x81399431}, {0x2F5A, 0x81399432}, {0x2F5B, 0x81399433}, {0x2F5C, 0x81399434}, {0x2F5D, 0x81399435}, {0x2F5E, 0x81399436}, {0x2F5F, 0x81399437}, {0x2F60, 0x81399438}, {0x2F61, 0x81399439}, {0x2F62, 0x81399530}, {0x2F63, 0x81399531}, {0x2F64, 0x81399532}, {0x2F65, 0x81399533}, {0x2F66, 0x81399534}, {0x2F67, 0x81399535}, {0x2F68, 0x81399536}, {0x2F69, 0x81399537}, {0x2F6A, 0x81399538}, {0x2F6B, 0x81399539}, {0x2F6C, 0x81399630}, {0x2F6D, 0x81399631}, {0x2F6E, 0x81399632}, {0x2F6F, 0x81399633}, {0x2F70, 0x81399634}, {0x2F71, 0x81399635}, {0x2F72, 0x81399636}, {0x2F73, 0x81399637}, {0x2F74, 0x81399638}, {0x2F75, 0x81399639}, {0x2F76, 0x81399730}, {0x2F77, 0x81399731}, {0x2F78, 0x81399732}, {0x2F79, 0x81399733}, {0x2F7A, 0x81399734}, {0x2F7B, 0x81399735}, {0x2F7C, 0x81399736}, {0x2F7D, 0x81399737}, {0x2F7E, 0x81399738}, {0x2F7F, 0x81399739}, {0x2F80, 0x81399830}, {0x2F81, 0x81399831}, {0x2F82, 0x81399832}, {0x2F83, 0x81399833}, {0x2F84, 0x81399834}, {0x2F85, 0x81399835}, {0x2F86, 0x81399836}, {0x2F87, 0x81399837}, {0x2F88, 0x81399838}, {0x2F89, 0x81399839}, {0x2F8A, 0x81399930}, {0x2F8B, 0x81399931}, {0x2F8C, 0x81399932}, {0x2F8D, 0x81399933}, {0x2F8E, 0x81399934}, {0x2F8F, 0x81399935}, {0x2F90, 0x81399936}, {0x2F91, 0x81399937}, {0x2F92, 0x81399938}, {0x2F93, 0x81399939}, {0x2F94, 0x81399A30}, {0x2F95, 0x81399A31}, {0x2F96, 0x81399A32}, {0x2F97, 0x81399A33}, {0x2F98, 0x81399A34}, {0x2F99, 0x81399A35}, {0x2F9A, 0x81399A36}, {0x2F9B, 0x81399A37}, {0x2F9C, 0x81399A38}, {0x2F9D, 0x81399A39}, {0x2F9E, 0x81399B30}, {0x2F9F, 0x81399B31}, {0x2FA0, 0x81399B32}, {0x2FA1, 0x81399B33}, {0x2FA2, 0x81399B34}, {0x2FA3, 0x81399B35}, {0x2FA4, 0x81399B36}, {0x2FA5, 0x81399B37}, {0x2FA6, 0x81399B38}, {0x2FA7, 0x81399B39}, {0x2FA8, 0x81399C30}, {0x2FA9, 0x81399C31}, {0x2FAA, 0x81399C32}, {0x2FAB, 0x81399C33}, {0x2FAC, 0x81399C34}, {0x2FAD, 0x81399C35}, {0x2FAE, 0x81399C36}, {0x2FAF, 0x81399C37}, {0x2FB0, 0x81399C38}, {0x2FB1, 0x81399C39}, {0x2FB2, 0x81399D30}, {0x2FB3, 0x81399D31}, {0x2FB4, 0x81399D32}, {0x2FB5, 0x81399D33}, {0x2FB6, 0x81399D34}, {0x2FB7, 0x81399D35}, {0x2FB8, 0x81399D36}, {0x2FB9, 0x81399D37}, {0x2FBA, 0x81399D38}, {0x2FBB, 0x81399D39}, {0x2FBC, 0x81399E30}, {0x2FBD, 0x81399E31}, {0x2FBE, 0x81399E32}, {0x2FBF, 0x81399E33}, {0x2FC0, 0x81399E34}, {0x2FC1, 0x81399E35}, {0x2FC2, 0x81399E36}, {0x2FC3, 0x81399E37}, {0x2FC4, 0x81399E38}, {0x2FC5, 0x81399E39}, {0x2FC6, 0x81399F30}, {0x2FC7, 0x81399F31}, {0x2FC8, 0x81399F32}, {0x2FC9, 0x81399F33}, {0x2FCA, 0x81399F34}, {0x2FCB, 0x81399F35}, {0x2FCC, 0x81399F36}, {0x2FCD, 0x81399F37}, {0x2FCE, 0x81399F38}, {0x2FCF, 0x81399F39}, {0x2FD0, 0x8139A030}, {0x2FD1, 0x8139A031}, {0x2FD2, 0x8139A032}, {0x2FD3, 0x8139A033}, {0x2FD4, 0x8139A034}, {0x2FD5, 0x8139A035}, {0x2FD6, 0x8139A036}, {0x2FD7, 0x8139A037}, {0x2FD8, 0x8139A038}, {0x2FD9, 0x8139A039}, {0x2FDA, 0x8139A130}, {0x2FDB, 0x8139A131}, {0x2FDC, 0x8139A132}, {0x2FDD, 0x8139A133}, {0x2FDE, 0x8139A134}, {0x2FDF, 0x8139A135}, {0x2FE0, 0x8139A136}, {0x2FE1, 0x8139A137}, {0x2FE2, 0x8139A138}, {0x2FE3, 0x8139A139}, {0x2FE4, 0x8139A230}, {0x2FE5, 0x8139A231}, {0x2FE6, 0x8139A232}, {0x2FE7, 0x8139A233}, {0x2FE8, 0x8139A234}, {0x2FE9, 0x8139A235}, {0x2FEA, 0x8139A236}, {0x2FEB, 0x8139A237}, {0x2FEC, 0x8139A238}, {0x2FED, 0x8139A239}, {0x2FEE, 0x8139A330}, {0x2FEF, 0x8139A331}, {0x2FFC, 0x8139A332}, {0x2FFD, 0x8139A333}, {0x2FFE, 0x8139A334}, {0x2FFF, 0x8139A335}, {0x3004, 0x8139A336}, {0x3018, 0x8139A337}, {0x3019, 0x8139A338}, {0x301A, 0x8139A339}, {0x301B, 0x8139A430}, {0x301C, 0x8139A431}, {0x301F, 0x8139A432}, {0x3020, 0x8139A433}, {0x302A, 0x8139A434}, {0x302B, 0x8139A435}, {0x302C, 0x8139A436}, {0x302D, 0x8139A437}, {0x302E, 0x8139A438}, {0x302F, 0x8139A439}, {0x3030, 0x8139A530}, {0x3031, 0x8139A531}, {0x3032, 0x8139A532}, {0x3033, 0x8139A533}, {0x3034, 0x8139A534}, {0x3035, 0x8139A535}, {0x3036, 0x8139A536}, {0x3037, 0x8139A537}, {0x3038, 0x8139A538}, {0x3039, 0x8139A539}, {0x303A, 0x8139A630}, {0x303B, 0x8139A631}, {0x303C, 0x8139A632}, {0x303D, 0x8139A633}, {0x303F, 0x8139A634}, {0x3040, 0x8139A635}, {0x3094, 0x8139A636}, {0x3095, 0x8139A637}, {0x3096, 0x8139A638}, {0x3097, 0x8139A639}, {0x3098, 0x8139A730}, {0x3099, 0x8139A731}, {0x309A, 0x8139A732}, {0x309F, 0x8139A733}, {0x30A0, 0x8139A734}, {0x30F7, 0x8139A735}, {0x30F8, 0x8139A736}, {0x30F9, 0x8139A737}, {0x30FA, 0x8139A738}, {0x30FB, 0x8139A739}, {0x30FF, 0x8139A830}, {0x3100, 0x8139A831}, {0x3101, 0x8139A832}, {0x3102, 0x8139A833}, {0x3103, 0x8139A834}, {0x3104, 0x8139A835}, {0x312A, 0x8139A836}, {0x312B, 0x8139A837}, {0x312C, 0x8139A838}, {0x312D, 0x8139A839}, {0x312E, 0x8139A930}, {0x312F, 0x8139A931}, {0x3130, 0x8139A932}, {0x3131, 0x8139A933}, {0x3132, 0x8139A934}, {0x3133, 0x8139A935}, {0x3134, 0x8139A936}, {0x3135, 0x8139A937}, {0x3136, 0x8139A938}, {0x3137, 0x8139A939}, {0x3138, 0x8139AA30}, {0x3139, 0x8139AA31}, {0x313A, 0x8139AA32}, {0x313B, 0x8139AA33}, {0x313C, 0x8139AA34}, {0x313D, 0x8139AA35}, {0x313E, 0x8139AA36}, {0x313F, 0x8139AA37}, {0x3140, 0x8139AA38}, {0x3141, 0x8139AA39}, {0x3142, 0x8139AB30}, {0x3143, 0x8139AB31}, {0x3144, 0x8139AB32}, {0x3145, 0x8139AB33}, {0x3146, 0x8139AB34}, {0x3147, 0x8139AB35}, {0x3148, 0x8139AB36}, {0x3149, 0x8139AB37}, {0x314A, 0x8139AB38}, {0x314B, 0x8139AB39}, {0x314C, 0x8139AC30}, {0x314D, 0x8139AC31}, {0x314E, 0x8139AC32}, {0x314F, 0x8139AC33}, {0x3150, 0x8139AC34}, {0x3151, 0x8139AC35}, {0x3152, 0x8139AC36}, {0x3153, 0x8139AC37}, {0x3154, 0x8139AC38}, {0x3155, 0x8139AC39}, {0x3156, 0x8139AD30}, {0x3157, 0x8139AD31}, {0x3158, 0x8139AD32}, {0x3159, 0x8139AD33}, {0x315A, 0x8139AD34}, {0x315B, 0x8139AD35}, {0x315C, 0x8139AD36}, {0x315D, 0x8139AD37}, {0x315E, 0x8139AD38}, {0x315F, 0x8139AD39}, {0x3160, 0x8139AE30}, {0x3161, 0x8139AE31}, {0x3162, 0x8139AE32}, {0x3163, 0x8139AE33}, {0x3164, 0x8139AE34}, {0x3165, 0x8139AE35}, {0x3166, 0x8139AE36}, {0x3167, 0x8139AE37}, {0x3168, 0x8139AE38}, {0x3169, 0x8139AE39}, {0x316A, 0x8139AF30}, {0x316B, 0x8139AF31}, {0x316C, 0x8139AF32}, {0x316D, 0x8139AF33}, {0x316E, 0x8139AF34}, {0x316F, 0x8139AF35}, {0x3170, 0x8139AF36}, {0x3171, 0x8139AF37}, {0x3172, 0x8139AF38}, {0x3173, 0x8139AF39}, {0x3174, 0x8139B030}, {0x3175, 0x8139B031}, {0x3176, 0x8139B032}, {0x3177, 0x8139B033}, {0x3178, 0x8139B034}, {0x3179, 0x8139B035}, {0x317A, 0x8139B036}, {0x317B, 0x8139B037}, {0x317C, 0x8139B038}, {0x317D, 0x8139B039}, {0x317E, 0x8139B130}, {0x317F, 0x8139B131}, {0x3180, 0x8139B132}, {0x3181, 0x8139B133}, {0x3182, 0x8139B134}, {0x3183, 0x8139B135}, {0x3184, 0x8139B136}, {0x3185, 0x8139B137}, {0x3186, 0x8139B138}, {0x3187, 0x8139B139}, {0x3188, 0x8139B230}, {0x3189, 0x8139B231}, {0x318A, 0x8139B232}, {0x318B, 0x8139B233}, {0x318C, 0x8139B234}, {0x318D, 0x8139B235}, {0x318E, 0x8139B236}, {0x318F, 0x8139B237}, {0x3190, 0x8139B238}, {0x3191, 0x8139B239}, {0x3192, 0x8139B330}, {0x3193, 0x8139B331}, {0x3194, 0x8139B332}, {0x3195, 0x8139B333}, {0x3196, 0x8139B334}, {0x3197, 0x8139B335}, {0x3198, 0x8139B336}, {0x3199, 0x8139B337}, {0x319A, 0x8139B338}, {0x319B, 0x8139B339}, {0x319C, 0x8139B430}, {0x319D, 0x8139B431}, {0x319E, 0x8139B432}, {0x319F, 0x8139B433}, {0x31A0, 0x8139B434}, {0x31A1, 0x8139B435}, {0x31A2, 0x8139B436}, {0x31A3, 0x8139B437}, {0x31A4, 0x8139B438}, {0x31A5, 0x8139B439}, {0x31A6, 0x8139B530}, {0x31A7, 0x8139B531}, {0x31A8, 0x8139B532}, {0x31A9, 0x8139B533}, {0x31AA, 0x8139B534}, {0x31AB, 0x8139B535}, {0x31AC, 0x8139B536}, {0x31AD, 0x8139B537}, {0x31AE, 0x8139B538}, {0x31AF, 0x8139B539}, {0x31B0, 0x8139B630}, {0x31B1, 0x8139B631}, {0x31B2, 0x8139B632}, {0x31B3, 0x8139B633}, {0x31B4, 0x8139B634}, {0x31B5, 0x8139B635}, {0x31B6, 0x8139B636}, {0x31B7, 0x8139B637}, {0x31B8, 0x8139B638}, {0x31B9, 0x8139B639}, {0x31BA, 0x8139B730}, {0x31BB, 0x8139B731}, {0x31BC, 0x8139B732}, {0x31BD, 0x8139B733}, {0x31BE, 0x8139B734}, {0x31BF, 0x8139B735}, {0x31C0, 0x8139B736}, {0x31C1, 0x8139B737}, {0x31C2, 0x8139B738}, {0x31C3, 0x8139B739}, {0x31C4, 0x8139B830}, {0x31C5, 0x8139B831}, {0x31C6, 0x8139B832}, {0x31C7, 0x8139B833}, {0x31C8, 0x8139B834}, {0x31C9, 0x8139B835}, {0x31CA, 0x8139B836}, {0x31CB, 0x8139B837}, {0x31CC, 0x8139B838}, {0x31CD, 0x8139B839}, {0x31CE, 0x8139B930}, {0x31CF, 0x8139B931}, {0x31D0, 0x8139B932}, {0x31D1, 0x8139B933}, {0x31D2, 0x8139B934}, {0x31D3, 0x8139B935}, {0x31D4, 0x8139B936}, {0x31D5, 0x8139B937}, {0x31D6, 0x8139B938}, {0x31D7, 0x8139B939}, {0x31D8, 0x8139BA30}, {0x31D9, 0x8139BA31}, {0x31DA, 0x8139BA32}, {0x31DB, 0x8139BA33}, {0x31DC, 0x8139BA34}, {0x31DD, 0x8139BA35}, {0x31DE, 0x8139BA36}, {0x31DF, 0x8139BA37}, {0x31E0, 0x8139BA38}, {0x31E1, 0x8139BA39}, {0x31E2, 0x8139BB30}, {0x31E3, 0x8139BB31}, {0x31E4, 0x8139BB32}, {0x31E5, 0x8139BB33}, {0x31E6, 0x8139BB34}, {0x31E7, 0x8139BB35}, {0x31E8, 0x8139BB36}, {0x31E9, 0x8139BB37}, {0x31EA, 0x8139BB38}, {0x31EB, 0x8139BB39}, {0x31EC, 0x8139BC30}, {0x31ED, 0x8139BC31}, {0x31EE, 0x8139BC32}, {0x31EF, 0x8139BC33}, {0x31F0, 0x8139BC34}, {0x31F1, 0x8139BC35}, {0x31F2, 0x8139BC36}, {0x31F3, 0x8139BC37}, {0x31F4, 0x8139BC38}, {0x31F5, 0x8139BC39}, {0x31F6, 0x8139BD30}, {0x31F7, 0x8139BD31}, {0x31F8, 0x8139BD32}, {0x31F9, 0x8139BD33}, {0x31FA, 0x8139BD34}, {0x31FB, 0x8139BD35}, {0x31FC, 0x8139BD36}, {0x31FD, 0x8139BD37}, {0x31FE, 0x8139BD38}, {0x31FF, 0x8139BD39}, {0x3200, 0x8139BE30}, {0x3201, 0x8139BE31}, {0x3202, 0x8139BE32}, {0x3203, 0x8139BE33}, {0x3204, 0x8139BE34}, {0x3205, 0x8139BE35}, {0x3206, 0x8139BE36}, {0x3207, 0x8139BE37}, {0x3208, 0x8139BE38}, {0x3209, 0x8139BE39}, {0x320A, 0x8139BF30}, {0x320B, 0x8139BF31}, {0x320C, 0x8139BF32}, {0x320D, 0x8139BF33}, {0x320E, 0x8139BF34}, {0x320F, 0x8139BF35}, {0x3210, 0x8139BF36}, {0x3211, 0x8139BF37}, {0x3212, 0x8139BF38}, {0x3213, 0x8139BF39}, {0x3214, 0x8139C030}, {0x3215, 0x8139C031}, {0x3216, 0x8139C032}, {0x3217, 0x8139C033}, {0x3218, 0x8139C034}, {0x3219, 0x8139C035}, {0x321A, 0x8139C036}, {0x321B, 0x8139C037}, {0x321C, 0x8139C038}, {0x321D, 0x8139C039}, {0x321E, 0x8139C130}, {0x321F, 0x8139C131}, {0x322A, 0x8139C132}, {0x322B, 0x8139C133}, {0x322C, 0x8139C134}, {0x322D, 0x8139C135}, {0x322E, 0x8139C136}, {0x322F, 0x8139C137}, {0x3230, 0x8139C138}, {0x3232, 0x8139C139}, {0x3233, 0x8139C230}, {0x3234, 0x8139C231}, {0x3235, 0x8139C232}, {0x3236, 0x8139C233}, {0x3237, 0x8139C234}, {0x3238, 0x8139C235}, {0x3239, 0x8139C236}, {0x323A, 0x8139C237}, {0x323B, 0x8139C238}, {0x323C, 0x8139C239}, {0x323D, 0x8139C330}, {0x323E, 0x8139C331}, {0x323F, 0x8139C332}, {0x3240, 0x8139C333}, {0x3241, 0x8139C334}, {0x3242, 0x8139C335}, {0x3243, 0x8139C336}, {0x3244, 0x8139C337}, {0x3245, 0x8139C338}, {0x3246, 0x8139C339}, {0x3247, 0x8139C430}, {0x3248, 0x8139C431}, {0x3249, 0x8139C432}, {0x324A, 0x8139C433}, {0x324B, 0x8139C434}, {0x324C, 0x8139C435}, {0x324D, 0x8139C436}, {0x324E, 0x8139C437}, {0x324F, 0x8139C438}, {0x3250, 0x8139C439}, {0x3251, 0x8139C530}, {0x3252, 0x8139C531}, {0x3253, 0x8139C532}, {0x3254, 0x8139C533}, {0x3255, 0x8139C534}, {0x3256, 0x8139C535}, {0x3257, 0x8139C536}, {0x3258, 0x8139C537}, {0x3259, 0x8139C538}, {0x325A, 0x8139C539}, {0x325B, 0x8139C630}, {0x325C, 0x8139C631}, {0x325D, 0x8139C632}, {0x325E, 0x8139C633}, {0x325F, 0x8139C634}, {0x3260, 0x8139C635}, {0x3261, 0x8139C636}, {0x3262, 0x8139C637}, {0x3263, 0x8139C638}, {0x3264, 0x8139C639}, {0x3265, 0x8139C730}, {0x3266, 0x8139C731}, {0x3267, 0x8139C732}, {0x3268, 0x8139C733}, {0x3269, 0x8139C734}, {0x326A, 0x8139C735}, {0x326B, 0x8139C736}, {0x326C, 0x8139C737}, {0x326D, 0x8139C738}, {0x326E, 0x8139C739}, {0x326F, 0x8139C830}, {0x3270, 0x8139C831}, {0x3271, 0x8139C832}, {0x3272, 0x8139C833}, {0x3273, 0x8139C834}, {0x3274, 0x8139C835}, {0x3275, 0x8139C836}, {0x3276, 0x8139C837}, {0x3277, 0x8139C838}, {0x3278, 0x8139C839}, {0x3279, 0x8139C930}, {0x327A, 0x8139C931}, {0x327B, 0x8139C932}, {0x327C, 0x8139C933}, {0x327D, 0x8139C934}, {0x327E, 0x8139C935}, {0x327F, 0x8139C936}, {0x3280, 0x8139C937}, {0x3281, 0x8139C938}, {0x3282, 0x8139C939}, {0x3283, 0x8139CA30}, {0x3284, 0x8139CA31}, {0x3285, 0x8139CA32}, {0x3286, 0x8139CA33}, {0x3287, 0x8139CA34}, {0x3288, 0x8139CA35}, {0x3289, 0x8139CA36}, {0x328A, 0x8139CA37}, {0x328B, 0x8139CA38}, {0x328C, 0x8139CA39}, {0x328D, 0x8139CB30}, {0x328E, 0x8139CB31}, {0x328F, 0x8139CB32}, {0x3290, 0x8139CB33}, {0x3291, 0x8139CB34}, {0x3292, 0x8139CB35}, {0x3293, 0x8139CB36}, {0x3294, 0x8139CB37}, {0x3295, 0x8139CB38}, {0x3296, 0x8139CB39}, {0x3297, 0x8139CC30}, {0x3298, 0x8139CC31}, {0x3299, 0x8139CC32}, {0x329A, 0x8139CC33}, {0x329B, 0x8139CC34}, {0x329C, 0x8139CC35}, {0x329D, 0x8139CC36}, {0x329E, 0x8139CC37}, {0x329F, 0x8139CC38}, {0x32A0, 0x8139CC39}, {0x32A1, 0x8139CD30}, {0x32A2, 0x8139CD31}, {0x32A4, 0x8139CD32}, {0x32A5, 0x8139CD33}, {0x32A6, 0x8139CD34}, {0x32A7, 0x8139CD35}, {0x32A8, 0x8139CD36}, {0x32A9, 0x8139CD37}, {0x32AA, 0x8139CD38}, {0x32AB, 0x8139CD39}, {0x32AC, 0x8139CE30}, {0x32AD, 0x8139CE31}, {0x32AE, 0x8139CE32}, {0x32AF, 0x8139CE33}, {0x32B0, 0x8139CE34}, {0x32B1, 0x8139CE35}, {0x32B2, 0x8139CE36}, {0x32B3, 0x8139CE37}, {0x32B4, 0x8139CE38}, {0x32B5, 0x8139CE39}, {0x32B6, 0x8139CF30}, {0x32B7, 0x8139CF31}, {0x32B8, 0x8139CF32}, {0x32B9, 0x8139CF33}, {0x32BA, 0x8139CF34}, {0x32BB, 0x8139CF35}, {0x32BC, 0x8139CF36}, {0x32BD, 0x8139CF37}, {0x32BE, 0x8139CF38}, {0x32BF, 0x8139CF39}, {0x32C0, 0x8139D030}, {0x32C1, 0x8139D031}, {0x32C2, 0x8139D032}, {0x32C3, 0x8139D033}, {0x32C4, 0x8139D034}, {0x32C5, 0x8139D035}, {0x32C6, 0x8139D036}, {0x32C7, 0x8139D037}, {0x32C8, 0x8139D038}, {0x32C9, 0x8139D039}, {0x32CA, 0x8139D130}, {0x32CB, 0x8139D131}, {0x32CC, 0x8139D132}, {0x32CD, 0x8139D133}, {0x32CE, 0x8139D134}, {0x32CF, 0x8139D135}, {0x32D0, 0x8139D136}, {0x32D1, 0x8139D137}, {0x32D2, 0x8139D138}, {0x32D3, 0x8139D139}, {0x32D4, 0x8139D230}, {0x32D5, 0x8139D231}, {0x32D6, 0x8139D232}, {0x32D7, 0x8139D233}, {0x32D8, 0x8139D234}, {0x32D9, 0x8139D235}, {0x32DA, 0x8139D236}, {0x32DB, 0x8139D237}, {0x32DC, 0x8139D238}, {0x32DD, 0x8139D239}, {0x32DE, 0x8139D330}, {0x32DF, 0x8139D331}, {0x32E0, 0x8139D332}, {0x32E1, 0x8139D333}, {0x32E2, 0x8139D334}, {0x32E3, 0x8139D335}, {0x32E4, 0x8139D336}, {0x32E5, 0x8139D337}, {0x32E6, 0x8139D338}, {0x32E7, 0x8139D339}, {0x32E8, 0x8139D430}, {0x32E9, 0x8139D431}, {0x32EA, 0x8139D432}, {0x32EB, 0x8139D433}, {0x32EC, 0x8139D434}, {0x32ED, 0x8139D435}, {0x32EE, 0x8139D436}, {0x32EF, 0x8139D437}, {0x32F0, 0x8139D438}, {0x32F1, 0x8139D439}, {0x32F2, 0x8139D530}, {0x32F3, 0x8139D531}, {0x32F4, 0x8139D532}, {0x32F5, 0x8139D533}, {0x32F6, 0x8139D534}, {0x32F7, 0x8139D535}, {0x32F8, 0x8139D536}, {0x32F9, 0x8139D537}, {0x32FA, 0x8139D538}, {0x32FB, 0x8139D539}, {0x32FC, 0x8139D630}, {0x32FD, 0x8139D631}, {0x32FE, 0x8139D632}, {0x32FF, 0x8139D633}, {0x3300, 0x8139D634}, {0x3301, 0x8139D635}, {0x3302, 0x8139D636}, {0x3303, 0x8139D637}, {0x3304, 0x8139D638}, {0x3305, 0x8139D639}, {0x3306, 0x8139D730}, {0x3307, 0x8139D731}, {0x3308, 0x8139D732}, {0x3309, 0x8139D733}, {0x330A, 0x8139D734}, {0x330B, 0x8139D735}, {0x330C, 0x8139D736}, {0x330D, 0x8139D737}, {0x330E, 0x8139D738}, {0x330F, 0x8139D739}, {0x3310, 0x8139D830}, {0x3311, 0x8139D831}, {0x3312, 0x8139D832}, {0x3313, 0x8139D833}, {0x3314, 0x8139D834}, {0x3315, 0x8139D835}, {0x3316, 0x8139D836}, {0x3317, 0x8139D837}, {0x3318, 0x8139D838}, {0x3319, 0x8139D839}, {0x331A, 0x8139D930}, {0x331B, 0x8139D931}, {0x331C, 0x8139D932}, {0x331D, 0x8139D933}, {0x331E, 0x8139D934}, {0x331F, 0x8139D935}, {0x3320, 0x8139D936}, {0x3321, 0x8139D937}, {0x3322, 0x8139D938}, {0x3323, 0x8139D939}, {0x3324, 0x8139DA30}, {0x3325, 0x8139DA31}, {0x3326, 0x8139DA32}, {0x3327, 0x8139DA33}, {0x3328, 0x8139DA34}, {0x3329, 0x8139DA35}, {0x332A, 0x8139DA36}, {0x332B, 0x8139DA37}, {0x332C, 0x8139DA38}, {0x332D, 0x8139DA39}, {0x332E, 0x8139DB30}, {0x332F, 0x8139DB31}, {0x3330, 0x8139DB32}, {0x3331, 0x8139DB33}, {0x3332, 0x8139DB34}, {0x3333, 0x8139DB35}, {0x3334, 0x8139DB36}, {0x3335, 0x8139DB37}, {0x3336, 0x8139DB38}, {0x3337, 0x8139DB39}, {0x3338, 0x8139DC30}, {0x3339, 0x8139DC31}, {0x333A, 0x8139DC32}, {0x333B, 0x8139DC33}, {0x333C, 0x8139DC34}, {0x333D, 0x8139DC35}, {0x333E, 0x8139DC36}, {0x333F, 0x8139DC37}, {0x3340, 0x8139DC38}, {0x3341, 0x8139DC39}, {0x3342, 0x8139DD30}, {0x3343, 0x8139DD31}, {0x3344, 0x8139DD32}, {0x3345, 0x8139DD33}, {0x3346, 0x8139DD34}, {0x3347, 0x8139DD35}, {0x3348, 0x8139DD36}, {0x3349, 0x8139DD37}, {0x334A, 0x8139DD38}, {0x334B, 0x8139DD39}, {0x334C, 0x8139DE30}, {0x334D, 0x8139DE31}, {0x334E, 0x8139DE32}, {0x334F, 0x8139DE33}, {0x3350, 0x8139DE34}, {0x3351, 0x8139DE35}, {0x3352, 0x8139DE36}, {0x3353, 0x8139DE37}, {0x3354, 0x8139DE38}, {0x3355, 0x8139DE39}, {0x3356, 0x8139DF30}, {0x3357, 0x8139DF31}, {0x3358, 0x8139DF32}, {0x3359, 0x8139DF33}, {0x335A, 0x8139DF34}, {0x335B, 0x8139DF35}, {0x335C, 0x8139DF36}, {0x335D, 0x8139DF37}, {0x335E, 0x8139DF38}, {0x335F, 0x8139DF39}, {0x3360, 0x8139E030}, {0x3361, 0x8139E031}, {0x3362, 0x8139E032}, {0x3363, 0x8139E033}, {0x3364, 0x8139E034}, {0x3365, 0x8139E035}, {0x3366, 0x8139E036}, {0x3367, 0x8139E037}, {0x3368, 0x8139E038}, {0x3369, 0x8139E039}, {0x336A, 0x8139E130}, {0x336B, 0x8139E131}, {0x336C, 0x8139E132}, {0x336D, 0x8139E133}, {0x336E, 0x8139E134}, {0x336F, 0x8139E135}, {0x3370, 0x8139E136}, {0x3371, 0x8139E137}, {0x3372, 0x8139E138}, {0x3373, 0x8139E139}, {0x3374, 0x8139E230}, {0x3375, 0x8139E231}, {0x3376, 0x8139E232}, {0x3377, 0x8139E233}, {0x3378, 0x8139E234}, {0x3379, 0x8139E235}, {0x337A, 0x8139E236}, {0x337B, 0x8139E237}, {0x337C, 0x8139E238}, {0x337D, 0x8139E239}, {0x337E, 0x8139E330}, {0x337F, 0x8139E331}, {0x3380, 0x8139E332}, {0x3381, 0x8139E333}, {0x3382, 0x8139E334}, {0x3383, 0x8139E335}, {0x3384, 0x8139E336}, {0x3385, 0x8139E337}, {0x3386, 0x8139E338}, {0x3387, 0x8139E339}, {0x3388, 0x8139E430}, {0x3389, 0x8139E431}, {0x338A, 0x8139E432}, {0x338B, 0x8139E433}, {0x338C, 0x8139E434}, {0x338D, 0x8139E435}, {0x3390, 0x8139E436}, {0x3391, 0x8139E437}, {0x3392, 0x8139E438}, {0x3393, 0x8139E439}, {0x3394, 0x8139E530}, {0x3395, 0x8139E531}, {0x3396, 0x8139E532}, {0x3397, 0x8139E533}, {0x3398, 0x8139E534}, {0x3399, 0x8139E535}, {0x339A, 0x8139E536}, {0x339B, 0x8139E537}, {0x339F, 0x8139E538}, {0x33A0, 0x8139E539}, {0x33A2, 0x8139E630}, {0x33A3, 0x8139E631}, {0x33A4, 0x8139E632}, {0x33A5, 0x8139E633}, {0x33A6, 0x8139E634}, {0x33A7, 0x8139E635}, {0x33A8, 0x8139E636}, {0x33A9, 0x8139E637}, {0x33AA, 0x8139E638}, {0x33AB, 0x8139E639}, {0x33AC, 0x8139E730}, {0x33AD, 0x8139E731}, {0x33AE, 0x8139E732}, {0x33AF, 0x8139E733}, {0x33B0, 0x8139E734}, {0x33B1, 0x8139E735}, {0x33B2, 0x8139E736}, {0x33B3, 0x8139E737}, {0x33B4, 0x8139E738}, {0x33B5, 0x8139E739}, {0x33B6, 0x8139E830}, {0x33B7, 0x8139E831}, {0x33B8, 0x8139E832}, {0x33B9, 0x8139E833}, {0x33BA, 0x8139E834}, {0x33BB, 0x8139E835}, {0x33BC, 0x8139E836}, {0x33BD, 0x8139E837}, {0x33BE, 0x8139E838}, {0x33BF, 0x8139E839}, {0x33C0, 0x8139E930}, {0x33C1, 0x8139E931}, {0x33C2, 0x8139E932}, {0x33C3, 0x8139E933}, {0x33C5, 0x8139E934}, {0x33C6, 0x8139E935}, {0x33C7, 0x8139E936}, {0x33C8, 0x8139E937}, {0x33C9, 0x8139E938}, {0x33CA, 0x8139E939}, {0x33CB, 0x8139EA30}, {0x33CC, 0x8139EA31}, {0x33CD, 0x8139EA32}, {0x33CF, 0x8139EA33}, {0x33D0, 0x8139EA34}, {0x33D3, 0x8139EA35}, {0x33D4, 0x8139EA36}, {0x33D6, 0x8139EA37}, {0x33D7, 0x8139EA38}, {0x33D8, 0x8139EA39}, {0x33D9, 0x8139EB30}, {0x33DA, 0x8139EB31}, {0x33DB, 0x8139EB32}, {0x33DC, 0x8139EB33}, {0x33DD, 0x8139EB34}, {0x33DE, 0x8139EB35}, {0x33DF, 0x8139EB36}, {0x33E0, 0x8139EB37}, {0x33E1, 0x8139EB38}, {0x33E2, 0x8139EB39}, {0x33E3, 0x8139EC30}, {0x33E4, 0x8139EC31}, {0x33E5, 0x8139EC32}, {0x33E6, 0x8139EC33}, {0x33E7, 0x8139EC34}, {0x33E8, 0x8139EC35}, {0x33E9, 0x8139EC36}, {0x33EA, 0x8139EC37}, {0x33EB, 0x8139EC38}, {0x33EC, 0x8139EC39}, {0x33ED, 0x8139ED30}, {0x33EE, 0x8139ED31}, {0x33EF, 0x8139ED32}, {0x33F0, 0x8139ED33}, {0x33F1, 0x8139ED34}, {0x33F2, 0x8139ED35}, {0x33F3, 0x8139ED36}, {0x33F4, 0x8139ED37}, {0x33F5, 0x8139ED38}, {0x33F6, 0x8139ED39}, {0x33F7, 0x8139EE30}, {0x33F8, 0x8139EE31}, {0x33F9, 0x8139EE32}, {0x33FA, 0x8139EE33}, {0x33FB, 0x8139EE34}, {0x33FC, 0x8139EE35}, {0x33FD, 0x8139EE36}, {0x33FE, 0x8139EE37}, {0x33FF, 0x8139EE38}, {0x3400, 0x8139EE39}, {0x3401, 0x8139EF30}, {0x3402, 0x8139EF31}, {0x3403, 0x8139EF32}, {0x3404, 0x8139EF33}, {0x3405, 0x8139EF34}, {0x3406, 0x8139EF35}, {0x3407, 0x8139EF36}, {0x3408, 0x8139EF37}, {0x3409, 0x8139EF38}, {0x340A, 0x8139EF39}, {0x340B, 0x8139F030}, {0x340C, 0x8139F031}, {0x340D, 0x8139F032}, {0x340E, 0x8139F033}, {0x340F, 0x8139F034}, {0x3410, 0x8139F035}, {0x3411, 0x8139F036}, {0x3412, 0x8139F037}, {0x3413, 0x8139F038}, {0x3414, 0x8139F039}, {0x3415, 0x8139F130}, {0x3416, 0x8139F131}, {0x3417, 0x8139F132}, {0x3418, 0x8139F133}, {0x3419, 0x8139F134}, {0x341A, 0x8139F135}, {0x341B, 0x8139F136}, {0x341C, 0x8139F137}, {0x341D, 0x8139F138}, {0x341E, 0x8139F139}, {0x341F, 0x8139F230}, {0x3420, 0x8139F231}, {0x3421, 0x8139F232}, {0x3422, 0x8139F233}, {0x3423, 0x8139F234}, {0x3424, 0x8139F235}, {0x3425, 0x8139F236}, {0x3426, 0x8139F237}, {0x3427, 0x8139F238}, {0x3428, 0x8139F239}, {0x3429, 0x8139F330}, {0x342A, 0x8139F331}, {0x342B, 0x8139F332}, {0x342C, 0x8139F333}, {0x342D, 0x8139F334}, {0x342E, 0x8139F335}, {0x342F, 0x8139F336}, {0x3430, 0x8139F337}, {0x3431, 0x8139F338}, {0x3432, 0x8139F339}, {0x3433, 0x8139F430}, {0x3434, 0x8139F431}, {0x3435, 0x8139F432}, {0x3436, 0x8139F433}, {0x3437, 0x8139F434}, {0x3438, 0x8139F435}, {0x3439, 0x8139F436}, {0x343A, 0x8139F437}, {0x343B, 0x8139F438}, {0x343C, 0x8139F439}, {0x343D, 0x8139F530}, {0x343E, 0x8139F531}, {0x343F, 0x8139F532}, {0x3440, 0x8139F533}, {0x3441, 0x8139F534}, {0x3442, 0x8139F535}, {0x3443, 0x8139F536}, {0x3444, 0x8139F537}, {0x3445, 0x8139F538}, {0x3446, 0x8139F539}, {0x3448, 0x8139F630}, {0x3449, 0x8139F631}, {0x344A, 0x8139F632}, {0x344B, 0x8139F633}, {0x344C, 0x8139F634}, {0x344D, 0x8139F635}, {0x344E, 0x8139F636}, {0x344F, 0x8139F637}, {0x3450, 0x8139F638}, {0x3451, 0x8139F639}, {0x3452, 0x8139F730}, {0x3453, 0x8139F731}, {0x3454, 0x8139F732}, {0x3455, 0x8139F733}, {0x3456, 0x8139F734}, {0x3457, 0x8139F735}, {0x3458, 0x8139F736}, {0x3459, 0x8139F737}, {0x345A, 0x8139F738}, {0x345B, 0x8139F739}, {0x345C, 0x8139F830}, {0x345D, 0x8139F831}, {0x345E, 0x8139F832}, {0x345F, 0x8139F833}, {0x3460, 0x8139F834}, {0x3461, 0x8139F835}, {0x3462, 0x8139F836}, {0x3463, 0x8139F837}, {0x3464, 0x8139F838}, {0x3465, 0x8139F839}, {0x3466, 0x8139F930}, {0x3467, 0x8139F931}, {0x3468, 0x8139F932}, {0x3469, 0x8139F933}, {0x346A, 0x8139F934}, {0x346B, 0x8139F935}, {0x346C, 0x8139F936}, {0x346D, 0x8139F937}, {0x346E, 0x8139F938}, {0x346F, 0x8139F939}, {0x3470, 0x8139FA30}, {0x3471, 0x8139FA31}, {0x3472, 0x8139FA32}, {0x3474, 0x8139FA33}, {0x3475, 0x8139FA34}, {0x3476, 0x8139FA35}, {0x3477, 0x8139FA36}, {0x3478, 0x8139FA37}, {0x3479, 0x8139FA38}, {0x347A, 0x8139FA39}, {0x347B, 0x8139FB30}, {0x347C, 0x8139FB31}, {0x347D, 0x8139FB32}, {0x347E, 0x8139FB33}, {0x347F, 0x8139FB34}, {0x3480, 0x8139FB35}, {0x3481, 0x8139FB36}, {0x3482, 0x8139FB37}, {0x3483, 0x8139FB38}, {0x3484, 0x8139FB39}, {0x3485, 0x8139FC30}, {0x3486, 0x8139FC31}, {0x3487, 0x8139FC32}, {0x3488, 0x8139FC33}, {0x3489, 0x8139FC34}, {0x348A, 0x8139FC35}, {0x348B, 0x8139FC36}, {0x348C, 0x8139FC37}, {0x348D, 0x8139FC38}, {0x348E, 0x8139FC39}, {0x348F, 0x8139FD30}, {0x3490, 0x8139FD31}, {0x3491, 0x8139FD32}, {0x3492, 0x8139FD33}, {0x3493, 0x8139FD34}, {0x3494, 0x8139FD35}, {0x3495, 0x8139FD36}, {0x3496, 0x8139FD37}, {0x3497, 0x8139FD38}, {0x3498, 0x8139FD39}, {0x3499, 0x8139FE30}, {0x349A, 0x8139FE31}, {0x349B, 0x8139FE32}, {0x349C, 0x8139FE33}, {0x349D, 0x8139FE34}, {0x349E, 0x8139FE35}, {0x349F, 0x8139FE36}, {0x34A0, 0x8139FE37}, {0x34A1, 0x8139FE38}, {0x34A2, 0x8139FE39}, {0x34A3, 0x82308130}, {0x34A4, 0x82308131}, {0x34A5, 0x82308132}, {0x34A6, 0x82308133}, {0x34A7, 0x82308134}, {0x34A8, 0x82308135}, {0x34A9, 0x82308136}, {0x34AA, 0x82308137}, {0x34AB, 0x82308138}, {0x34AC, 0x82308139}, {0x34AD, 0x82308230}, {0x34AE, 0x82308231}, {0x34AF, 0x82308232}, {0x34B0, 0x82308233}, {0x34B1, 0x82308234}, {0x34B2, 0x82308235}, {0x34B3, 0x82308236}, {0x34B4, 0x82308237}, {0x34B5, 0x82308238}, {0x34B6, 0x82308239}, {0x34B7, 0x82308330}, {0x34B8, 0x82308331}, {0x34B9, 0x82308332}, {0x34BA, 0x82308333}, {0x34BB, 0x82308334}, {0x34BC, 0x82308335}, {0x34BD, 0x82308336}, {0x34BE, 0x82308337}, {0x34BF, 0x82308338}, {0x34C0, 0x82308339}, {0x34C1, 0x82308430}, {0x34C2, 0x82308431}, {0x34C3, 0x82308432}, {0x34C4, 0x82308433}, {0x34C5, 0x82308434}, {0x34C6, 0x82308435}, {0x34C7, 0x82308436}, {0x34C8, 0x82308437}, {0x34C9, 0x82308438}, {0x34CA, 0x82308439}, {0x34CB, 0x82308530}, {0x34CC, 0x82308531}, {0x34CD, 0x82308532}, {0x34CE, 0x82308533}, {0x34CF, 0x82308534}, {0x34D0, 0x82308535}, {0x34D1, 0x82308536}, {0x34D2, 0x82308537}, {0x34D3, 0x82308538}, {0x34D4, 0x82308539}, {0x34D5, 0x82308630}, {0x34D6, 0x82308631}, {0x34D7, 0x82308632}, {0x34D8, 0x82308633}, {0x34D9, 0x82308634}, {0x34DA, 0x82308635}, {0x34DB, 0x82308636}, {0x34DC, 0x82308637}, {0x34DD, 0x82308638}, {0x34DE, 0x82308639}, {0x34DF, 0x82308730}, {0x34E0, 0x82308731}, {0x34E1, 0x82308732}, {0x34E2, 0x82308733}, {0x34E3, 0x82308734}, {0x34E4, 0x82308735}, {0x34E5, 0x82308736}, {0x34E6, 0x82308737}, {0x34E7, 0x82308738}, {0x34E8, 0x82308739}, {0x34E9, 0x82308830}, {0x34EA, 0x82308831}, {0x34EB, 0x82308832}, {0x34EC, 0x82308833}, {0x34ED, 0x82308834}, {0x34EE, 0x82308835}, {0x34EF, 0x82308836}, {0x34F0, 0x82308837}, {0x34F1, 0x82308838}, {0x34F2, 0x82308839}, {0x34F3, 0x82308930}, {0x34F4, 0x82308931}, {0x34F5, 0x82308932}, {0x34F6, 0x82308933}, {0x34F7, 0x82308934}, {0x34F8, 0x82308935}, {0x34F9, 0x82308936}, {0x34FA, 0x82308937}, {0x34FB, 0x82308938}, {0x34FC, 0x82308939}, {0x34FD, 0x82308A30}, {0x34FE, 0x82308A31}, {0x34FF, 0x82308A32}, {0x3500, 0x82308A33}, {0x3501, 0x82308A34}, {0x3502, 0x82308A35}, {0x3503, 0x82308A36}, {0x3504, 0x82308A37}, {0x3505, 0x82308A38}, {0x3506, 0x82308A39}, {0x3507, 0x82308B30}, {0x3508, 0x82308B31}, {0x3509, 0x82308B32}, {0x350A, 0x82308B33}, {0x350B, 0x82308B34}, {0x350C, 0x82308B35}, {0x350D, 0x82308B36}, {0x350E, 0x82308B37}, {0x350F, 0x82308B38}, {0x3510, 0x82308B39}, {0x3511, 0x82308C30}, {0x3512, 0x82308C31}, {0x3513, 0x82308C32}, {0x3514, 0x82308C33}, {0x3515, 0x82308C34}, {0x3516, 0x82308C35}, {0x3517, 0x82308C36}, {0x3518, 0x82308C37}, {0x3519, 0x82308C38}, {0x351A, 0x82308C39}, {0x351B, 0x82308D30}, {0x351C, 0x82308D31}, {0x351D, 0x82308D32}, {0x351E, 0x82308D33}, {0x351F, 0x82308D34}, {0x3520, 0x82308D35}, {0x3521, 0x82308D36}, {0x3522, 0x82308D37}, {0x3523, 0x82308D38}, {0x3524, 0x82308D39}, {0x3525, 0x82308E30}, {0x3526, 0x82308E31}, {0x3527, 0x82308E32}, {0x3528, 0x82308E33}, {0x3529, 0x82308E34}, {0x352A, 0x82308E35}, {0x352B, 0x82308E36}, {0x352C, 0x82308E37}, {0x352D, 0x82308E38}, {0x352E, 0x82308E39}, {0x352F, 0x82308F30}, {0x3530, 0x82308F31}, {0x3531, 0x82308F32}, {0x3532, 0x82308F33}, {0x3533, 0x82308F34}, {0x3534, 0x82308F35}, {0x3535, 0x82308F36}, {0x3536, 0x82308F37}, {0x3537, 0x82308F38}, {0x3538, 0x82308F39}, {0x3539, 0x82309030}, {0x353A, 0x82309031}, {0x353B, 0x82309032}, {0x353C, 0x82309033}, {0x353D, 0x82309034}, {0x353E, 0x82309035}, {0x353F, 0x82309036}, {0x3540, 0x82309037}, {0x3541, 0x82309038}, {0x3542, 0x82309039}, {0x3543, 0x82309130}, {0x3544, 0x82309131}, {0x3545, 0x82309132}, {0x3546, 0x82309133}, {0x3547, 0x82309134}, {0x3548, 0x82309135}, {0x3549, 0x82309136}, {0x354A, 0x82309137}, {0x354B, 0x82309138}, {0x354C, 0x82309139}, {0x354D, 0x82309230}, {0x354E, 0x82309231}, {0x354F, 0x82309232}, {0x3550, 0x82309233}, {0x3551, 0x82309234}, {0x3552, 0x82309235}, {0x3553, 0x82309236}, {0x3554, 0x82309237}, {0x3555, 0x82309238}, {0x3556, 0x82309239}, {0x3557, 0x82309330}, {0x3558, 0x82309331}, {0x3559, 0x82309332}, {0x355A, 0x82309333}, {0x355B, 0x82309334}, {0x355C, 0x82309335}, {0x355D, 0x82309336}, {0x355E, 0x82309337}, {0x355F, 0x82309338}, {0x3560, 0x82309339}, {0x3561, 0x82309430}, {0x3562, 0x82309431}, {0x3563, 0x82309432}, {0x3564, 0x82309433}, {0x3565, 0x82309434}, {0x3566, 0x82309435}, {0x3567, 0x82309436}, {0x3568, 0x82309437}, {0x3569, 0x82309438}, {0x356A, 0x82309439}, {0x356B, 0x82309530}, {0x356C, 0x82309531}, {0x356D, 0x82309532}, {0x356E, 0x82309533}, {0x356F, 0x82309534}, {0x3570, 0x82309535}, {0x3571, 0x82309536}, {0x3572, 0x82309537}, {0x3573, 0x82309538}, {0x3574, 0x82309539}, {0x3575, 0x82309630}, {0x3576, 0x82309631}, {0x3577, 0x82309632}, {0x3578, 0x82309633}, {0x3579, 0x82309634}, {0x357A, 0x82309635}, {0x357B, 0x82309636}, {0x357C, 0x82309637}, {0x357D, 0x82309638}, {0x357E, 0x82309639}, {0x357F, 0x82309730}, {0x3580, 0x82309731}, {0x3581, 0x82309732}, {0x3582, 0x82309733}, {0x3583, 0x82309734}, {0x3584, 0x82309735}, {0x3585, 0x82309736}, {0x3586, 0x82309737}, {0x3587, 0x82309738}, {0x3588, 0x82309739}, {0x3589, 0x82309830}, {0x358A, 0x82309831}, {0x358B, 0x82309832}, {0x358C, 0x82309833}, {0x358D, 0x82309834}, {0x358E, 0x82309835}, {0x358F, 0x82309836}, {0x3590, 0x82309837}, {0x3591, 0x82309838}, {0x3592, 0x82309839}, {0x3593, 0x82309930}, {0x3594, 0x82309931}, {0x3595, 0x82309932}, {0x3596, 0x82309933}, {0x3597, 0x82309934}, {0x3598, 0x82309935}, {0x3599, 0x82309936}, {0x359A, 0x82309937}, {0x359B, 0x82309938}, {0x359C, 0x82309939}, {0x359D, 0x82309A30}, {0x359F, 0x82309A31}, {0x35A0, 0x82309A32}, {0x35A1, 0x82309A33}, {0x35A2, 0x82309A34}, {0x35A3, 0x82309A35}, {0x35A4, 0x82309A36}, {0x35A5, 0x82309A37}, {0x35A6, 0x82309A38}, {0x35A7, 0x82309A39}, {0x35A8, 0x82309B30}, {0x35A9, 0x82309B31}, {0x35AA, 0x82309B32}, {0x35AB, 0x82309B33}, {0x35AC, 0x82309B34}, {0x35AD, 0x82309B35}, {0x35AE, 0x82309B36}, {0x35AF, 0x82309B37}, {0x35B0, 0x82309B38}, {0x35B1, 0x82309B39}, {0x35B2, 0x82309C30}, {0x35B3, 0x82309C31}, {0x35B4, 0x82309C32}, {0x35B5, 0x82309C33}, {0x35B6, 0x82309C34}, {0x35B7, 0x82309C35}, {0x35B8, 0x82309C36}, {0x35B9, 0x82309C37}, {0x35BA, 0x82309C38}, {0x35BB, 0x82309C39}, {0x35BC, 0x82309D30}, {0x35BD, 0x82309D31}, {0x35BE, 0x82309D32}, {0x35BF, 0x82309D33}, {0x35C0, 0x82309D34}, {0x35C1, 0x82309D35}, {0x35C2, 0x82309D36}, {0x35C3, 0x82309D37}, {0x35C4, 0x82309D38}, {0x35C5, 0x82309D39}, {0x35C6, 0x82309E30}, {0x35C7, 0x82309E31}, {0x35C8, 0x82309E32}, {0x35C9, 0x82309E33}, {0x35CA, 0x82309E34}, {0x35CB, 0x82309E35}, {0x35CC, 0x82309E36}, {0x35CD, 0x82309E37}, {0x35CE, 0x82309E38}, {0x35CF, 0x82309E39}, {0x35D0, 0x82309F30}, {0x35D1, 0x82309F31}, {0x35D2, 0x82309F32}, {0x35D3, 0x82309F33}, {0x35D4, 0x82309F34}, {0x35D5, 0x82309F35}, {0x35D6, 0x82309F36}, {0x35D7, 0x82309F37}, {0x35D8, 0x82309F38}, {0x35D9, 0x82309F39}, {0x35DA, 0x8230A030}, {0x35DB, 0x8230A031}, {0x35DC, 0x8230A032}, {0x35DD, 0x8230A033}, {0x35DE, 0x8230A034}, {0x35DF, 0x8230A035}, {0x35E0, 0x8230A036}, {0x35E1, 0x8230A037}, {0x35E2, 0x8230A038}, {0x35E3, 0x8230A039}, {0x35E4, 0x8230A130}, {0x35E5, 0x8230A131}, {0x35E6, 0x8230A132}, {0x35E7, 0x8230A133}, {0x35E8, 0x8230A134}, {0x35E9, 0x8230A135}, {0x35EA, 0x8230A136}, {0x35EB, 0x8230A137}, {0x35EC, 0x8230A138}, {0x35ED, 0x8230A139}, {0x35EE, 0x8230A230}, {0x35EF, 0x8230A231}, {0x35F0, 0x8230A232}, {0x35F1, 0x8230A233}, {0x35F2, 0x8230A234}, {0x35F3, 0x8230A235}, {0x35F4, 0x8230A236}, {0x35F5, 0x8230A237}, {0x35F6, 0x8230A238}, {0x35F7, 0x8230A239}, {0x35F8, 0x8230A330}, {0x35F9, 0x8230A331}, {0x35FA, 0x8230A332}, {0x35FB, 0x8230A333}, {0x35FC, 0x8230A334}, {0x35FD, 0x8230A335}, {0x35FE, 0x8230A336}, {0x35FF, 0x8230A337}, {0x3600, 0x8230A338}, {0x3601, 0x8230A339}, {0x3602, 0x8230A430}, {0x3603, 0x8230A431}, {0x3604, 0x8230A432}, {0x3605, 0x8230A433}, {0x3606, 0x8230A434}, {0x3607, 0x8230A435}, {0x3608, 0x8230A436}, {0x3609, 0x8230A437}, {0x360A, 0x8230A438}, {0x360B, 0x8230A439}, {0x360C, 0x8230A530}, {0x360D, 0x8230A531}, {0x360F, 0x8230A532}, {0x3610, 0x8230A533}, {0x3611, 0x8230A534}, {0x3612, 0x8230A535}, {0x3613, 0x8230A536}, {0x3614, 0x8230A537}, {0x3615, 0x8230A538}, {0x3616, 0x8230A539}, {0x3617, 0x8230A630}, {0x3618, 0x8230A631}, {0x3619, 0x8230A632}, {0x3919, 0x8230F238}, {0x391A, 0x8230F239}, {0x391B, 0x8230F330}, {0x391C, 0x8230F331}, {0x391D, 0x8230F332}, {0x391E, 0x8230F333}, {0x391F, 0x8230F334}, {0x3920, 0x8230F335}, {0x3921, 0x8230F336}, {0x3922, 0x8230F337}, {0x3923, 0x8230F338}, {0x3924, 0x8230F339}, {0x3925, 0x8230F430}, {0x3926, 0x8230F431}, {0x3927, 0x8230F432}, {0x3928, 0x8230F433}, {0x3929, 0x8230F434}, {0x392A, 0x8230F435}, {0x392B, 0x8230F436}, {0x392C, 0x8230F437}, {0x392D, 0x8230F438}, {0x392E, 0x8230F439}, {0x392F, 0x8230F530}, {0x3930, 0x8230F531}, {0x3931, 0x8230F532}, {0x3932, 0x8230F533}, {0x3933, 0x8230F534}, {0x3934, 0x8230F535}, {0x3935, 0x8230F536}, {0x3936, 0x8230F537}, {0x3937, 0x8230F538}, {0x3938, 0x8230F539}, {0x3939, 0x8230F630}, {0x393A, 0x8230F631}, {0x393B, 0x8230F632}, {0x393C, 0x8230F633}, {0x393D, 0x8230F634}, {0x393E, 0x8230F635}, {0x393F, 0x8230F636}, {0x3940, 0x8230F637}, {0x3941, 0x8230F638}, {0x3942, 0x8230F639}, {0x3943, 0x8230F730}, {0x3944, 0x8230F731}, {0x3945, 0x8230F732}, {0x3946, 0x8230F733}, {0x3947, 0x8230F734}, {0x3948, 0x8230F735}, {0x3949, 0x8230F736}, {0x394A, 0x8230F737}, {0x394B, 0x8230F738}, {0x394C, 0x8230F739}, {0x394D, 0x8230F830}, {0x394E, 0x8230F831}, {0x394F, 0x8230F832}, {0x3950, 0x8230F833}, {0x3951, 0x8230F834}, {0x3952, 0x8230F835}, {0x3953, 0x8230F836}, {0x3954, 0x8230F837}, {0x3955, 0x8230F838}, {0x3956, 0x8230F839}, {0x3957, 0x8230F930}, {0x3958, 0x8230F931}, {0x3959, 0x8230F932}, {0x395A, 0x8230F933}, {0x395B, 0x8230F934}, {0x395C, 0x8230F935}, {0x395D, 0x8230F936}, {0x395E, 0x8230F937}, {0x395F, 0x8230F938}, {0x3960, 0x8230F939}, {0x3961, 0x8230FA30}, {0x3962, 0x8230FA31}, {0x3963, 0x8230FA32}, {0x3964, 0x8230FA33}, {0x3965, 0x8230FA34}, {0x3966, 0x8230FA35}, {0x3967, 0x8230FA36}, {0x3968, 0x8230FA37}, {0x3969, 0x8230FA38}, {0x396A, 0x8230FA39}, {0x396B, 0x8230FB30}, {0x396C, 0x8230FB31}, {0x396D, 0x8230FB32}, {0x396F, 0x8230FB33}, {0x3970, 0x8230FB34}, {0x3971, 0x8230FB35}, {0x3972, 0x8230FB36}, {0x3973, 0x8230FB37}, {0x3974, 0x8230FB38}, {0x3975, 0x8230FB39}, {0x3976, 0x8230FC30}, {0x3977, 0x8230FC31}, {0x3978, 0x8230FC32}, {0x3979, 0x8230FC33}, {0x397A, 0x8230FC34}, {0x397B, 0x8230FC35}, {0x397C, 0x8230FC36}, {0x397D, 0x8230FC37}, {0x397E, 0x8230FC38}, {0x397F, 0x8230FC39}, {0x3980, 0x8230FD30}, {0x3981, 0x8230FD31}, {0x3982, 0x8230FD32}, {0x3983, 0x8230FD33}, {0x3984, 0x8230FD34}, {0x3985, 0x8230FD35}, {0x3986, 0x8230FD36}, {0x3987, 0x8230FD37}, {0x3988, 0x8230FD38}, {0x3989, 0x8230FD39}, {0x398A, 0x8230FE30}, {0x398B, 0x8230FE31}, {0x398C, 0x8230FE32}, {0x398D, 0x8230FE33}, {0x398E, 0x8230FE34}, {0x398F, 0x8230FE35}, {0x3990, 0x8230FE36}, {0x3991, 0x8230FE37}, {0x3992, 0x8230FE38}, {0x3993, 0x8230FE39}, {0x3994, 0x82318130}, {0x3995, 0x82318131}, {0x3996, 0x82318132}, {0x3997, 0x82318133}, {0x3998, 0x82318134}, {0x3999, 0x82318135}, {0x399A, 0x82318136}, {0x399B, 0x82318137}, {0x399C, 0x82318138}, {0x399D, 0x82318139}, {0x399E, 0x82318230}, {0x399F, 0x82318231}, {0x39A0, 0x82318232}, {0x39A1, 0x82318233}, {0x39A2, 0x82318234}, {0x39A3, 0x82318235}, {0x39A4, 0x82318236}, {0x39A5, 0x82318237}, {0x39A6, 0x82318238}, {0x39A7, 0x82318239}, {0x39A8, 0x82318330}, {0x39A9, 0x82318331}, {0x39AA, 0x82318332}, {0x39AB, 0x82318333}, {0x39AC, 0x82318334}, {0x39AD, 0x82318335}, {0x39AE, 0x82318336}, {0x39AF, 0x82318337}, {0x39B0, 0x82318338}, {0x39B1, 0x82318339}, {0x39B2, 0x82318430}, {0x39B3, 0x82318431}, {0x39B4, 0x82318432}, {0x39B5, 0x82318433}, {0x39B6, 0x82318434}, {0x39B7, 0x82318435}, {0x39B8, 0x82318436}, {0x39B9, 0x82318437}, {0x39BA, 0x82318438}, {0x39BB, 0x82318439}, {0x39BC, 0x82318530}, {0x39BD, 0x82318531}, {0x39BE, 0x82318532}, {0x39BF, 0x82318533}, {0x39C0, 0x82318534}, {0x39C1, 0x82318535}, {0x39C2, 0x82318536}, {0x39C3, 0x82318537}, {0x39C4, 0x82318538}, {0x39C5, 0x82318539}, {0x39C6, 0x82318630}, {0x39C7, 0x82318631}, {0x39C8, 0x82318632}, {0x39C9, 0x82318633}, {0x39CA, 0x82318634}, {0x39CB, 0x82318635}, {0x39CC, 0x82318636}, {0x39CD, 0x82318637}, {0x39CE, 0x82318638}, {0x39D1, 0x82318639}, {0x39D2, 0x82318730}, {0x39D3, 0x82318731}, {0x39D4, 0x82318732}, {0x39D5, 0x82318733}, {0x39D6, 0x82318734}, {0x39D7, 0x82318735}, {0x39D8, 0x82318736}, {0x39D9, 0x82318737}, {0x39DA, 0x82318738}, {0x39DB, 0x82318739}, {0x39DC, 0x82318830}, {0x39DD, 0x82318831}, {0x39DE, 0x82318832}, {0x39E0, 0x82318833}, {0x39E1, 0x82318834}, {0x39E2, 0x82318835}, {0x39E3, 0x82318836}, {0x39E4, 0x82318837}, {0x39E5, 0x82318838}, {0x39E6, 0x82318839}, {0x39E7, 0x82318930}, {0x39E8, 0x82318931}, {0x39E9, 0x82318932}, {0x39EA, 0x82318933}, {0x39EB, 0x82318934}, {0x39EC, 0x82318935}, {0x39ED, 0x82318936}, {0x39EE, 0x82318937}, {0x39EF, 0x82318938}, {0x39F0, 0x82318939}, {0x39F1, 0x82318A30}, {0x39F2, 0x82318A31}, {0x39F3, 0x82318A32}, {0x39F4, 0x82318A33}, {0x39F5, 0x82318A34}, {0x39F6, 0x82318A35}, {0x39F7, 0x82318A36}, {0x39F8, 0x82318A37}, {0x39F9, 0x82318A38}, {0x39FA, 0x82318A39}, {0x39FB, 0x82318B30}, {0x39FC, 0x82318B31}, {0x39FD, 0x82318B32}, {0x39FE, 0x82318B33}, {0x39FF, 0x82318B34}, {0x3A00, 0x82318B35}, {0x3A01, 0x82318B36}, {0x3A02, 0x82318B37}, {0x3A03, 0x82318B38}, {0x3A04, 0x82318B39}, {0x3A05, 0x82318C30}, {0x3A06, 0x82318C31}, {0x3A07, 0x82318C32}, {0x3A08, 0x82318C33}, {0x3A09, 0x82318C34}, {0x3A0A, 0x82318C35}, {0x3A0B, 0x82318C36}, {0x3A0C, 0x82318C37}, {0x3A0D, 0x82318C38}, {0x3A0E, 0x82318C39}, {0x3A0F, 0x82318D30}, {0x3A10, 0x82318D31}, {0x3A11, 0x82318D32}, {0x3A12, 0x82318D33}, {0x3A13, 0x82318D34}, {0x3A14, 0x82318D35}, {0x3A15, 0x82318D36}, {0x3A16, 0x82318D37}, {0x3A17, 0x82318D38}, {0x3A18, 0x82318D39}, {0x3A19, 0x82318E30}, {0x3A1A, 0x82318E31}, {0x3A1B, 0x82318E32}, {0x3A1C, 0x82318E33}, {0x3A1D, 0x82318E34}, {0x3A1E, 0x82318E35}, {0x3A1F, 0x82318E36}, {0x3A20, 0x82318E37}, {0x3A21, 0x82318E38}, {0x3A22, 0x82318E39}, {0x3A23, 0x82318F30}, {0x3A24, 0x82318F31}, {0x3A25, 0x82318F32}, {0x3A26, 0x82318F33}, {0x3A27, 0x82318F34}, {0x3A28, 0x82318F35}, {0x3A29, 0x82318F36}, {0x3A2A, 0x82318F37}, {0x3A2B, 0x82318F38}, {0x3A2C, 0x82318F39}, {0x3A2D, 0x82319030}, {0x3A2E, 0x82319031}, {0x3A2F, 0x82319032}, {0x3A30, 0x82319033}, {0x3A31, 0x82319034}, {0x3A32, 0x82319035}, {0x3A33, 0x82319036}, {0x3A34, 0x82319037}, {0x3A35, 0x82319038}, {0x3A36, 0x82319039}, {0x3A37, 0x82319130}, {0x3A38, 0x82319131}, {0x3A39, 0x82319132}, {0x3A3A, 0x82319133}, {0x3A3B, 0x82319134}, {0x3A3C, 0x82319135}, {0x3A3D, 0x82319136}, {0x3A3E, 0x82319137}, {0x3A3F, 0x82319138}, {0x3A40, 0x82319139}, {0x3A41, 0x82319230}, {0x3A42, 0x82319231}, {0x3A43, 0x82319232}, {0x3A44, 0x82319233}, {0x3A45, 0x82319234}, {0x3A46, 0x82319235}, {0x3A47, 0x82319236}, {0x3A48, 0x82319237}, {0x3A49, 0x82319238}, {0x3A4A, 0x82319239}, {0x3A4B, 0x82319330}, {0x3A4C, 0x82319331}, {0x3A4D, 0x82319332}, {0x3A4E, 0x82319333}, {0x3A4F, 0x82319334}, {0x3A50, 0x82319335}, {0x3A51, 0x82319336}, {0x3A52, 0x82319337}, {0x3A53, 0x82319338}, {0x3A54, 0x82319339}, {0x3A55, 0x82319430}, {0x3A56, 0x82319431}, {0x3A57, 0x82319432}, {0x3A58, 0x82319433}, {0x3A59, 0x82319434}, {0x3A5A, 0x82319435}, {0x3A5B, 0x82319436}, {0x3A5C, 0x82319437}, {0x3A5D, 0x82319438}, {0x3A5E, 0x82319439}, {0x3A5F, 0x82319530}, {0x3A60, 0x82319531}, {0x3A61, 0x82319532}, {0x3A62, 0x82319533}, {0x3A63, 0x82319534}, {0x3A64, 0x82319535}, {0x3A65, 0x82319536}, {0x3A66, 0x82319537}, {0x3A67, 0x82319538}, {0x3A68, 0x82319539}, {0x3A69, 0x82319630}, {0x3A6A, 0x82319631}, {0x3A6B, 0x82319632}, {0x3A6C, 0x82319633}, {0x3A6D, 0x82319634}, {0x3A6E, 0x82319635}, {0x3A6F, 0x82319636}, {0x3A70, 0x82319637}, {0x3A71, 0x82319638}, {0x3A72, 0x82319639}, {0x3A74, 0x82319730}, {0x3A75, 0x82319731}, {0x3A76, 0x82319732}, {0x3A77, 0x82319733}, {0x3A78, 0x82319734}, {0x3A79, 0x82319735}, {0x3A7A, 0x82319736}, {0x3A7B, 0x82319737}, {0x3A7C, 0x82319738}, {0x3A7D, 0x82319739}, {0x3A7E, 0x82319830}, {0x3A7F, 0x82319831}, {0x3A80, 0x82319832}, {0x3A81, 0x82319833}, {0x3A82, 0x82319834}, {0x3A83, 0x82319835}, {0x3A84, 0x82319836}, {0x3A85, 0x82319837}, {0x3A86, 0x82319838}, {0x3A87, 0x82319839}, {0x3A88, 0x82319930}, {0x3A89, 0x82319931}, {0x3A8A, 0x82319932}, {0x3A8B, 0x82319933}, {0x3A8C, 0x82319934}, {0x3A8D, 0x82319935}, {0x3A8E, 0x82319936}, {0x3A8F, 0x82319937}, {0x3A90, 0x82319938}, {0x3A91, 0x82319939}, {0x3A92, 0x82319A30}, {0x3A93, 0x82319A31}, {0x3A94, 0x82319A32}, {0x3A95, 0x82319A33}, {0x3A96, 0x82319A34}, {0x3A97, 0x82319A35}, {0x3A98, 0x82319A36}, {0x3A99, 0x82319A37}, {0x3A9A, 0x82319A38}, {0x3A9B, 0x82319A39}, {0x3A9C, 0x82319B30}, {0x3A9D, 0x82319B31}, {0x3A9E, 0x82319B32}, {0x3A9F, 0x82319B33}, {0x3AA0, 0x82319B34}, {0x3AA1, 0x82319B35}, {0x3AA2, 0x82319B36}, {0x3AA3, 0x82319B37}, {0x3AA4, 0x82319B38}, {0x3AA5, 0x82319B39}, {0x3AA6, 0x82319C30}, {0x3AA7, 0x82319C31}, {0x3AA8, 0x82319C32}, {0x3AA9, 0x82319C33}, {0x3AAA, 0x82319C34}, {0x3AAB, 0x82319C35}, {0x3AAC, 0x82319C36}, {0x3AAD, 0x82319C37}, {0x3AAE, 0x82319C38}, {0x3AAF, 0x82319C39}, {0x3AB0, 0x82319D30}, {0x3AB1, 0x82319D31}, {0x3AB2, 0x82319D32}, {0x3AB3, 0x82319D33}, {0x3AB4, 0x82319D34}, {0x3AB5, 0x82319D35}, {0x3AB6, 0x82319D36}, {0x3AB7, 0x82319D37}, {0x3AB8, 0x82319D38}, {0x3AB9, 0x82319D39}, {0x3ABA, 0x82319E30}, {0x3ABB, 0x82319E31}, {0x3ABC, 0x82319E32}, {0x3ABD, 0x82319E33}, {0x3ABE, 0x82319E34}, {0x3ABF, 0x82319E35}, {0x3AC0, 0x82319E36}, {0x3AC1, 0x82319E37}, {0x3AC2, 0x82319E38}, {0x3AC3, 0x82319E39}, {0x3AC4, 0x82319F30}, {0x3AC5, 0x82319F31}, {0x3AC6, 0x82319F32}, {0x3AC7, 0x82319F33}, {0x3AC8, 0x82319F34}, {0x3AC9, 0x82319F35}, {0x3ACA, 0x82319F36}, {0x3ACB, 0x82319F37}, {0x3ACC, 0x82319F38}, {0x3ACD, 0x82319F39}, {0x3ACE, 0x8231A030}, {0x3ACF, 0x8231A031}, {0x3AD0, 0x8231A032}, {0x3AD1, 0x8231A033}, {0x3AD2, 0x8231A034}, {0x3AD3, 0x8231A035}, {0x3AD4, 0x8231A036}, {0x3AD5, 0x8231A037}, {0x3AD6, 0x8231A038}, {0x3AD7, 0x8231A039}, {0x3AD8, 0x8231A130}, {0x3AD9, 0x8231A131}, {0x3ADA, 0x8231A132}, {0x3ADB, 0x8231A133}, {0x3ADC, 0x8231A134}, {0x3ADD, 0x8231A135}, {0x3ADE, 0x8231A136}, {0x3ADF, 0x8231A137}, {0x3AE0, 0x8231A138}, {0x3AE1, 0x8231A139}, {0x3AE2, 0x8231A230}, {0x3AE3, 0x8231A231}, {0x3AE4, 0x8231A232}, {0x3AE5, 0x8231A233}, {0x3AE6, 0x8231A234}, {0x3AE7, 0x8231A235}, {0x3AE8, 0x8231A236}, {0x3AE9, 0x8231A237}, {0x3AEA, 0x8231A238}, {0x3AEB, 0x8231A239}, {0x3AEC, 0x8231A330}, {0x3AED, 0x8231A331}, {0x3AEE, 0x8231A332}, {0x3AEF, 0x8231A333}, {0x3AF0, 0x8231A334}, {0x3AF1, 0x8231A335}, {0x3AF2, 0x8231A336}, {0x3AF3, 0x8231A337}, {0x3AF4, 0x8231A338}, {0x3AF5, 0x8231A339}, {0x3AF6, 0x8231A430}, {0x3AF7, 0x8231A431}, {0x3AF8, 0x8231A432}, {0x3AF9, 0x8231A433}, {0x3AFA, 0x8231A434}, {0x3AFB, 0x8231A435}, {0x3AFC, 0x8231A436}, {0x3AFD, 0x8231A437}, {0x3AFE, 0x8231A438}, {0x3AFF, 0x8231A439}, {0x3B00, 0x8231A530}, {0x3B01, 0x8231A531}, {0x3B02, 0x8231A532}, {0x3B03, 0x8231A533}, {0x3B04, 0x8231A534}, {0x3B05, 0x8231A535}, {0x3B06, 0x8231A536}, {0x3B07, 0x8231A537}, {0x3B08, 0x8231A538}, {0x3B09, 0x8231A539}, {0x3B0A, 0x8231A630}, {0x3B0B, 0x8231A631}, {0x3B0C, 0x8231A632}, {0x3B0D, 0x8231A633}, {0x3B0E, 0x8231A634}, {0x3B0F, 0x8231A635}, {0x3B10, 0x8231A636}, {0x3B11, 0x8231A637}, {0x3B12, 0x8231A638}, {0x3B13, 0x8231A639}, {0x3B14, 0x8231A730}, {0x3B15, 0x8231A731}, {0x3B16, 0x8231A732}, {0x3B17, 0x8231A733}, {0x3B18, 0x8231A734}, {0x3B19, 0x8231A735}, {0x3B1A, 0x8231A736}, {0x3B1B, 0x8231A737}, {0x3B1C, 0x8231A738}, {0x3B1D, 0x8231A739}, {0x3B1E, 0x8231A830}, {0x3B1F, 0x8231A831}, {0x3B20, 0x8231A832}, {0x3B21, 0x8231A833}, {0x3B22, 0x8231A834}, {0x3B23, 0x8231A835}, {0x3B24, 0x8231A836}, {0x3B25, 0x8231A837}, {0x3B26, 0x8231A838}, {0x3B27, 0x8231A839}, {0x3B28, 0x8231A930}, {0x3B29, 0x8231A931}, {0x3B2A, 0x8231A932}, {0x3B2B, 0x8231A933}, {0x3B2C, 0x8231A934}, {0x3B2D, 0x8231A935}, {0x3B2E, 0x8231A936}, {0x3B2F, 0x8231A937}, {0x3B30, 0x8231A938}, {0x3B31, 0x8231A939}, {0x3B32, 0x8231AA30}, {0x3B33, 0x8231AA31}, {0x3B34, 0x8231AA32}, {0x3B35, 0x8231AA33}, {0x3B36, 0x8231AA34}, {0x3B37, 0x8231AA35}, {0x3B38, 0x8231AA36}, {0x3B39, 0x8231AA37}, {0x3B3A, 0x8231AA38}, {0x3B3B, 0x8231AA39}, {0x3B3C, 0x8231AB30}, {0x3B3D, 0x8231AB31}, {0x3B3E, 0x8231AB32}, {0x3B3F, 0x8231AB33}, {0x3B40, 0x8231AB34}, {0x3B41, 0x8231AB35}, {0x3B42, 0x8231AB36}, {0x3B43, 0x8231AB37}, {0x3B44, 0x8231AB38}, {0x3B45, 0x8231AB39}, {0x3B46, 0x8231AC30}, {0x3B47, 0x8231AC31}, {0x3B48, 0x8231AC32}, {0x3B49, 0x8231AC33}, {0x3B4A, 0x8231AC34}, {0x3B4B, 0x8231AC35}, {0x3B4C, 0x8231AC36}, {0x3B4D, 0x8231AC37}, {0x3B4F, 0x8231AC38}, {0x3B50, 0x8231AC39}, {0x3B51, 0x8231AD30}, {0x3B52, 0x8231AD31}, {0x3B53, 0x8231AD32}, {0x3B54, 0x8231AD33}, {0x3B55, 0x8231AD34}, {0x3B56, 0x8231AD35}, {0x3B57, 0x8231AD36}, {0x3B58, 0x8231AD37}, {0x3B59, 0x8231AD38}, {0x3B5A, 0x8231AD39}, {0x3B5B, 0x8231AE30}, {0x3B5C, 0x8231AE31}, {0x3B5D, 0x8231AE32}, {0x3B5E, 0x8231AE33}, {0x3B5F, 0x8231AE34}, {0x3B60, 0x8231AE35}, {0x3B61, 0x8231AE36}, {0x3B62, 0x8231AE37}, {0x3B63, 0x8231AE38}, {0x3B64, 0x8231AE39}, {0x3B65, 0x8231AF30}, {0x3B66, 0x8231AF31}, {0x3B67, 0x8231AF32}, {0x3B68, 0x8231AF33}, {0x3B69, 0x8231AF34}, {0x3B6A, 0x8231AF35}, {0x3B6B, 0x8231AF36}, {0x3B6C, 0x8231AF37}, {0x3B6D, 0x8231AF38}, {0x3B6E, 0x8231AF39}, {0x3B6F, 0x8231B030}, {0x3B70, 0x8231B031}, {0x3B71, 0x8231B032}, {0x3B72, 0x8231B033}, {0x3B73, 0x8231B034}, {0x3B74, 0x8231B035}, {0x3B75, 0x8231B036}, {0x3B76, 0x8231B037}, {0x3B77, 0x8231B038}, {0x3B78, 0x8231B039}, {0x3B79, 0x8231B130}, {0x3B7A, 0x8231B131}, {0x3B7B, 0x8231B132}, {0x3B7C, 0x8231B133}, {0x3B7D, 0x8231B134}, {0x3B7E, 0x8231B135}, {0x3B7F, 0x8231B136}, {0x3B80, 0x8231B137}, {0x3B81, 0x8231B138}, {0x3B82, 0x8231B139}, {0x3B83, 0x8231B230}, {0x3B84, 0x8231B231}, {0x3B85, 0x8231B232}, {0x3B86, 0x8231B233}, {0x3B87, 0x8231B234}, {0x3B88, 0x8231B235}, {0x3B89, 0x8231B236}, {0x3B8A, 0x8231B237}, {0x3B8B, 0x8231B238}, {0x3B8C, 0x8231B239}, {0x3B8D, 0x8231B330}, {0x3B8E, 0x8231B331}, {0x3B8F, 0x8231B332}, {0x3B90, 0x8231B333}, {0x3B91, 0x8231B334}, {0x3B92, 0x8231B335}, {0x3B93, 0x8231B336}, {0x3B94, 0x8231B337}, {0x3B95, 0x8231B338}, {0x3B96, 0x8231B339}, {0x3B97, 0x8231B430}, {0x3B98, 0x8231B431}, {0x3B99, 0x8231B432}, {0x3B9A, 0x8231B433}, {0x3B9B, 0x8231B434}, {0x3B9C, 0x8231B435}, {0x3B9D, 0x8231B436}, {0x3B9E, 0x8231B437}, {0x3B9F, 0x8231B438}, {0x3BA0, 0x8231B439}, {0x3BA1, 0x8231B530}, {0x3BA2, 0x8231B531}, {0x3BA3, 0x8231B532}, {0x3BA4, 0x8231B533}, {0x3BA5, 0x8231B534}, {0x3BA6, 0x8231B535}, {0x3BA7, 0x8231B536}, {0x3BA8, 0x8231B537}, {0x3BA9, 0x8231B538}, {0x3BAA, 0x8231B539}, {0x3BAB, 0x8231B630}, {0x3BAC, 0x8231B631}, {0x3BAD, 0x8231B632}, {0x3BAE, 0x8231B633}, {0x3BAF, 0x8231B634}, {0x3BB0, 0x8231B635}, {0x3BB1, 0x8231B636}, {0x3BB2, 0x8231B637}, {0x3BB3, 0x8231B638}, {0x3BB4, 0x8231B639}, {0x3BB5, 0x8231B730}, {0x3BB6, 0x8231B731}, {0x3BB7, 0x8231B732}, {0x3BB8, 0x8231B733}, {0x3BB9, 0x8231B734}, {0x3BBA, 0x8231B735}, {0x3BBB, 0x8231B736}, {0x3BBC, 0x8231B737}, {0x3BBD, 0x8231B738}, {0x3BBE, 0x8231B739}, {0x3BBF, 0x8231B830}, {0x3BC0, 0x8231B831}, {0x3BC1, 0x8231B832}, {0x3BC2, 0x8231B833}, {0x3BC3, 0x8231B834}, {0x3BC4, 0x8231B835}, {0x3BC5, 0x8231B836}, {0x3BC6, 0x8231B837}, {0x3BC7, 0x8231B838}, {0x3BC8, 0x8231B839}, {0x3BC9, 0x8231B930}, {0x3BCA, 0x8231B931}, {0x3BCB, 0x8231B932}, {0x3BCC, 0x8231B933}, {0x3BCD, 0x8231B934}, {0x3BCE, 0x8231B935}, {0x3BCF, 0x8231B936}, {0x3BD0, 0x8231B937}, {0x3BD1, 0x8231B938}, {0x3BD2, 0x8231B939}, {0x3BD3, 0x8231BA30}, {0x3BD4, 0x8231BA31}, {0x3BD5, 0x8231BA32}, {0x3BD6, 0x8231BA33}, {0x3BD7, 0x8231BA34}, {0x3BD8, 0x8231BA35}, {0x3BD9, 0x8231BA36}, {0x3BDA, 0x8231BA37}, {0x3BDB, 0x8231BA38}, {0x3BDC, 0x8231BA39}, {0x3BDD, 0x8231BB30}, {0x3BDE, 0x8231BB31}, {0x3BDF, 0x8231BB32}, {0x3BE0, 0x8231BB33}, {0x3BE1, 0x8231BB34}, {0x3BE2, 0x8231BB35}, {0x3BE3, 0x8231BB36}, {0x3BE4, 0x8231BB37}, {0x3BE5, 0x8231BB38}, {0x3BE6, 0x8231BB39}, {0x3BE7, 0x8231BC30}, {0x3BE8, 0x8231BC31}, {0x3BE9, 0x8231BC32}, {0x3BEA, 0x8231BC33}, {0x3BEB, 0x8231BC34}, {0x3BEC, 0x8231BC35}, {0x3BED, 0x8231BC36}, {0x3BEE, 0x8231BC37}, {0x3BEF, 0x8231BC38}, {0x3BF0, 0x8231BC39}, {0x3BF1, 0x8231BD30}, {0x3BF2, 0x8231BD31}, {0x3BF3, 0x8231BD32}, {0x3BF4, 0x8231BD33}, {0x3BF5, 0x8231BD34}, {0x3BF6, 0x8231BD35}, {0x3BF7, 0x8231BD36}, {0x3BF8, 0x8231BD37}, {0x3BF9, 0x8231BD38}, {0x3BFA, 0x8231BD39}, {0x3BFB, 0x8231BE30}, {0x3BFC, 0x8231BE31}, {0x3BFD, 0x8231BE32}, {0x3BFE, 0x8231BE33}, {0x3BFF, 0x8231BE34}, {0x3C00, 0x8231BE35}, {0x3C01, 0x8231BE36}, {0x3C02, 0x8231BE37}, {0x3C03, 0x8231BE38}, {0x3C04, 0x8231BE39}, {0x3C05, 0x8231BF30}, {0x3C06, 0x8231BF31}, {0x3C07, 0x8231BF32}, {0x3C08, 0x8231BF33}, {0x3C09, 0x8231BF34}, {0x3C0A, 0x8231BF35}, {0x3C0B, 0x8231BF36}, {0x3C0C, 0x8231BF37}, {0x3C0D, 0x8231BF38}, {0x3C0E, 0x8231BF39}, {0x3C0F, 0x8231C030}, {0x3C10, 0x8231C031}, {0x3C11, 0x8231C032}, {0x3C12, 0x8231C033}, {0x3C13, 0x8231C034}, {0x3C14, 0x8231C035}, {0x3C15, 0x8231C036}, {0x3C16, 0x8231C037}, {0x3C17, 0x8231C038}, {0x3C18, 0x8231C039}, {0x3C19, 0x8231C130}, {0x3C1A, 0x8231C131}, {0x3C1B, 0x8231C132}, {0x3C1C, 0x8231C133}, {0x3C1D, 0x8231C134}, {0x3C1E, 0x8231C135}, {0x3C1F, 0x8231C136}, {0x3C20, 0x8231C137}, {0x3C21, 0x8231C138}, {0x3C22, 0x8231C139}, {0x3C23, 0x8231C230}, {0x3C24, 0x8231C231}, {0x3C25, 0x8231C232}, {0x3C26, 0x8231C233}, {0x3C27, 0x8231C234}, {0x3C28, 0x8231C235}, {0x3C29, 0x8231C236}, {0x3C2A, 0x8231C237}, {0x3C2B, 0x8231C238}, {0x3C2C, 0x8231C239}, {0x3C2D, 0x8231C330}, {0x3C2E, 0x8231C331}, {0x3C2F, 0x8231C332}, {0x3C30, 0x8231C333}, {0x3C31, 0x8231C334}, {0x3C32, 0x8231C335}, {0x3C33, 0x8231C336}, {0x3C34, 0x8231C337}, {0x3C35, 0x8231C338}, {0x3C36, 0x8231C339}, {0x3C37, 0x8231C430}, {0x3C38, 0x8231C431}, {0x3C39, 0x8231C432}, {0x3C3A, 0x8231C433}, {0x3C3B, 0x8231C434}, {0x3C3C, 0x8231C435}, {0x3C3D, 0x8231C436}, {0x3C3E, 0x8231C437}, {0x3C3F, 0x8231C438}, {0x3C40, 0x8231C439}, {0x3C41, 0x8231C530}, {0x3C42, 0x8231C531}, {0x3C43, 0x8231C532}, {0x3C44, 0x8231C533}, {0x3C45, 0x8231C534}, {0x3C46, 0x8231C535}, {0x3C47, 0x8231C536}, {0x3C48, 0x8231C537}, {0x3C49, 0x8231C538}, {0x3C4A, 0x8231C539}, {0x3C4B, 0x8231C630}, {0x3C4C, 0x8231C631}, {0x3C4D, 0x8231C632}, {0x3C4E, 0x8231C633}, {0x3C4F, 0x8231C634}, {0x3C50, 0x8231C635}, {0x3C51, 0x8231C636}, {0x3C52, 0x8231C637}, {0x3C53, 0x8231C638}, {0x3C54, 0x8231C639}, {0x3C55, 0x8231C730}, {0x3C56, 0x8231C731}, {0x3C57, 0x8231C732}, {0x3C58, 0x8231C733}, {0x3C59, 0x8231C734}, {0x3C5A, 0x8231C735}, {0x3C5B, 0x8231C736}, {0x3C5C, 0x8231C737}, {0x3C5D, 0x8231C738}, {0x3C5E, 0x8231C739}, {0x3C5F, 0x8231C830}, {0x3C60, 0x8231C831}, {0x3C61, 0x8231C832}, {0x3C62, 0x8231C833}, {0x3C63, 0x8231C834}, {0x3C64, 0x8231C835}, {0x3C65, 0x8231C836}, {0x3C66, 0x8231C837}, {0x3C67, 0x8231C838}, {0x3C68, 0x8231C839}, {0x3C69, 0x8231C930}, {0x3C6A, 0x8231C931}, {0x3C6B, 0x8231C932}, {0x3C6C, 0x8231C933}, {0x3C6D, 0x8231C934}, {0x3C6F, 0x8231C935}, {0x3C70, 0x8231C936}, {0x3C71, 0x8231C937}, {0x3C72, 0x8231C938}, {0x3C73, 0x8231C939}, {0x3C74, 0x8231CA30}, {0x3C75, 0x8231CA31}, {0x3C76, 0x8231CA32}, {0x3C77, 0x8231CA33}, {0x3C78, 0x8231CA34}, {0x3C79, 0x8231CA35}, {0x3C7A, 0x8231CA36}, {0x3C7B, 0x8231CA37}, {0x3C7C, 0x8231CA38}, {0x3C7D, 0x8231CA39}, {0x3C7E, 0x8231CB30}, {0x3C7F, 0x8231CB31}, {0x3C80, 0x8231CB32}, {0x3C81, 0x8231CB33}, {0x3C82, 0x8231CB34}, {0x3C83, 0x8231CB35}, {0x3C84, 0x8231CB36}, {0x3C85, 0x8231CB37}, {0x3C86, 0x8231CB38}, {0x3C87, 0x8231CB39}, {0x3C88, 0x8231CC30}, {0x3C89, 0x8231CC31}, {0x3C8A, 0x8231CC32}, {0x3C8B, 0x8231CC33}, {0x3C8C, 0x8231CC34}, {0x3C8D, 0x8231CC35}, {0x3C8E, 0x8231CC36}, {0x3C8F, 0x8231CC37}, {0x3C90, 0x8231CC38}, {0x3C91, 0x8231CC39}, {0x3C92, 0x8231CD30}, {0x3C93, 0x8231CD31}, {0x3C94, 0x8231CD32}, {0x3C95, 0x8231CD33}, {0x3C96, 0x8231CD34}, {0x3C97, 0x8231CD35}, {0x3C98, 0x8231CD36}, {0x3C99, 0x8231CD37}, {0x3C9A, 0x8231CD38}, {0x3C9B, 0x8231CD39}, {0x3C9C, 0x8231CE30}, {0x3C9D, 0x8231CE31}, {0x3C9E, 0x8231CE32}, {0x3C9F, 0x8231CE33}, {0x3CA0, 0x8231CE34}, {0x3CA1, 0x8231CE35}, {0x3CA2, 0x8231CE36}, {0x3CA3, 0x8231CE37}, {0x3CA4, 0x8231CE38}, {0x3CA5, 0x8231CE39}, {0x3CA6, 0x8231CF30}, {0x3CA7, 0x8231CF31}, {0x3CA8, 0x8231CF32}, {0x3CA9, 0x8231CF33}, {0x3CAA, 0x8231CF34}, {0x3CAB, 0x8231CF35}, {0x3CAC, 0x8231CF36}, {0x3CAD, 0x8231CF37}, {0x3CAE, 0x8231CF38}, {0x3CAF, 0x8231CF39}, {0x3CB0, 0x8231D030}, {0x3CB1, 0x8231D031}, {0x3CB2, 0x8231D032}, {0x3CB3, 0x8231D033}, {0x3CB4, 0x8231D034}, {0x3CB5, 0x8231D035}, {0x3CB6, 0x8231D036}, {0x3CB7, 0x8231D037}, {0x3CB8, 0x8231D038}, {0x3CB9, 0x8231D039}, {0x3CBA, 0x8231D130}, {0x3CBB, 0x8231D131}, {0x3CBC, 0x8231D132}, {0x3CBD, 0x8231D133}, {0x3CBE, 0x8231D134}, {0x3CBF, 0x8231D135}, {0x3CC0, 0x8231D136}, {0x3CC1, 0x8231D137}, {0x3CC2, 0x8231D138}, {0x3CC3, 0x8231D139}, {0x3CC4, 0x8231D230}, {0x3CC5, 0x8231D231}, {0x3CC6, 0x8231D232}, {0x3CC7, 0x8231D233}, {0x3CC8, 0x8231D234}, {0x3CC9, 0x8231D235}, {0x3CCA, 0x8231D236}, {0x3CCB, 0x8231D237}, {0x3CCC, 0x8231D238}, {0x3CCD, 0x8231D239}, {0x3CCE, 0x8231D330}, {0x3CCF, 0x8231D331}, {0x3CD0, 0x8231D332}, {0x3CD1, 0x8231D333}, {0x3CD2, 0x8231D334}, {0x3CD3, 0x8231D335}, {0x3CD4, 0x8231D336}, {0x3CD5, 0x8231D337}, {0x3CD6, 0x8231D338}, {0x3CD7, 0x8231D339}, {0x3CD8, 0x8231D430}, {0x3CD9, 0x8231D431}, {0x3CDA, 0x8231D432}, {0x3CDB, 0x8231D433}, {0x3CDC, 0x8231D434}, {0x3CDD, 0x8231D435}, {0x3CDE, 0x8231D436}, {0x3CDF, 0x8231D437}, {0x4057, 0x8232AF33}, {0x4058, 0x8232AF34}, {0x4059, 0x8232AF35}, {0x405A, 0x8232AF36}, {0x405B, 0x8232AF37}, {0x405C, 0x8232AF38}, {0x405D, 0x8232AF39}, {0x405E, 0x8232B030}, {0x405F, 0x8232B031}, {0x4060, 0x8232B032}, {0x4061, 0x8232B033}, {0x4062, 0x8232B034}, {0x4063, 0x8232B035}, {0x4064, 0x8232B036}, {0x4065, 0x8232B037}, {0x4066, 0x8232B038}, {0x4067, 0x8232B039}, {0x4068, 0x8232B130}, {0x4069, 0x8232B131}, {0x406A, 0x8232B132}, {0x406B, 0x8232B133}, {0x406C, 0x8232B134}, {0x406D, 0x8232B135}, {0x406E, 0x8232B136}, {0x406F, 0x8232B137}, {0x4070, 0x8232B138}, {0x4071, 0x8232B139}, {0x4072, 0x8232B230}, {0x4073, 0x8232B231}, {0x4074, 0x8232B232}, {0x4075, 0x8232B233}, {0x4076, 0x8232B234}, {0x4077, 0x8232B235}, {0x4078, 0x8232B236}, {0x4079, 0x8232B237}, {0x407A, 0x8232B238}, {0x407B, 0x8232B239}, {0x407C, 0x8232B330}, {0x407D, 0x8232B331}, {0x407E, 0x8232B332}, {0x407F, 0x8232B333}, {0x4080, 0x8232B334}, {0x4081, 0x8232B335}, {0x4082, 0x8232B336}, {0x4083, 0x8232B337}, {0x4084, 0x8232B338}, {0x4085, 0x8232B339}, {0x4086, 0x8232B430}, {0x4087, 0x8232B431}, {0x4088, 0x8232B432}, {0x4089, 0x8232B433}, {0x408A, 0x8232B434}, {0x408B, 0x8232B435}, {0x408C, 0x8232B436}, {0x408D, 0x8232B437}, {0x408E, 0x8232B438}, {0x408F, 0x8232B439}, {0x4090, 0x8232B530}, {0x4091, 0x8232B531}, {0x4092, 0x8232B532}, {0x4093, 0x8232B533}, {0x4094, 0x8232B534}, {0x4095, 0x8232B535}, {0x4096, 0x8232B536}, {0x4097, 0x8232B537}, {0x4098, 0x8232B538}, {0x4099, 0x8232B539}, {0x409A, 0x8232B630}, {0x409B, 0x8232B631}, {0x409C, 0x8232B632}, {0x409D, 0x8232B633}, {0x409E, 0x8232B634}, {0x409F, 0x8232B635}, {0x40A0, 0x8232B636}, {0x40A1, 0x8232B637}, {0x40A2, 0x8232B638}, {0x40A3, 0x8232B639}, {0x40A4, 0x8232B730}, {0x40A5, 0x8232B731}, {0x40A6, 0x8232B732}, {0x40A7, 0x8232B733}, {0x40A8, 0x8232B734}, {0x40A9, 0x8232B735}, {0x40AA, 0x8232B736}, {0x40AB, 0x8232B737}, {0x40AC, 0x8232B738}, {0x40AD, 0x8232B739}, {0x40AE, 0x8232B830}, {0x40AF, 0x8232B831}, {0x40B0, 0x8232B832}, {0x40B1, 0x8232B833}, {0x40B2, 0x8232B834}, {0x40B3, 0x8232B835}, {0x40B4, 0x8232B836}, {0x40B5, 0x8232B837}, {0x40B6, 0x8232B838}, {0x40B7, 0x8232B839}, {0x40B8, 0x8232B930}, {0x40B9, 0x8232B931}, {0x40BA, 0x8232B932}, {0x40BB, 0x8232B933}, {0x40BC, 0x8232B934}, {0x40BD, 0x8232B935}, {0x40BE, 0x8232B936}, {0x40BF, 0x8232B937}, {0x40C0, 0x8232B938}, {0x40C1, 0x8232B939}, {0x40C2, 0x8232BA30}, {0x40C3, 0x8232BA31}, {0x40C4, 0x8232BA32}, {0x40C5, 0x8232BA33}, {0x40C6, 0x8232BA34}, {0x40C7, 0x8232BA35}, {0x40C8, 0x8232BA36}, {0x40C9, 0x8232BA37}, {0x40CA, 0x8232BA38}, {0x40CB, 0x8232BA39}, {0x40CC, 0x8232BB30}, {0x40CD, 0x8232BB31}, {0x40CE, 0x8232BB32}, {0x40CF, 0x8232BB33}, {0x40D0, 0x8232BB34}, {0x40D1, 0x8232BB35}, {0x40D2, 0x8232BB36}, {0x40D3, 0x8232BB37}, {0x40D4, 0x8232BB38}, {0x40D5, 0x8232BB39}, {0x40D6, 0x8232BC30}, {0x40D7, 0x8232BC31}, {0x40D8, 0x8232BC32}, {0x40D9, 0x8232BC33}, {0x40DA, 0x8232BC34}, {0x40DB, 0x8232BC35}, {0x40DC, 0x8232BC36}, {0x40DD, 0x8232BC37}, {0x40DE, 0x8232BC38}, {0x40DF, 0x8232BC39}, {0x40E0, 0x8232BD30}, {0x40E1, 0x8232BD31}, {0x40E2, 0x8232BD32}, {0x40E3, 0x8232BD33}, {0x40E4, 0x8232BD34}, {0x40E5, 0x8232BD35}, {0x40E6, 0x8232BD36}, {0x40E7, 0x8232BD37}, {0x40E8, 0x8232BD38}, {0x40E9, 0x8232BD39}, {0x40EA, 0x8232BE30}, {0x40EB, 0x8232BE31}, {0x40EC, 0x8232BE32}, {0x40ED, 0x8232BE33}, {0x40EE, 0x8232BE34}, {0x40EF, 0x8232BE35}, {0x40F0, 0x8232BE36}, {0x40F1, 0x8232BE37}, {0x40F2, 0x8232BE38}, {0x40F3, 0x8232BE39}, {0x40F4, 0x8232BF30}, {0x40F5, 0x8232BF31}, {0x40F6, 0x8232BF32}, {0x40F7, 0x8232BF33}, {0x40F8, 0x8232BF34}, {0x40F9, 0x8232BF35}, {0x40FA, 0x8232BF36}, {0x40FB, 0x8232BF37}, {0x40FC, 0x8232BF38}, {0x40FD, 0x8232BF39}, {0x40FE, 0x8232C030}, {0x40FF, 0x8232C031}, {0x4100, 0x8232C032}, {0x4101, 0x8232C033}, {0x4102, 0x8232C034}, {0x4103, 0x8232C035}, {0x4104, 0x8232C036}, {0x4105, 0x8232C037}, {0x4106, 0x8232C038}, {0x4107, 0x8232C039}, {0x4108, 0x8232C130}, {0x4109, 0x8232C131}, {0x410A, 0x8232C132}, {0x410B, 0x8232C133}, {0x410C, 0x8232C134}, {0x410D, 0x8232C135}, {0x410E, 0x8232C136}, {0x410F, 0x8232C137}, {0x4110, 0x8232C138}, {0x4111, 0x8232C139}, {0x4112, 0x8232C230}, {0x4113, 0x8232C231}, {0x4114, 0x8232C232}, {0x4115, 0x8232C233}, {0x4116, 0x8232C234}, {0x4117, 0x8232C235}, {0x4118, 0x8232C236}, {0x4119, 0x8232C237}, {0x411A, 0x8232C238}, {0x411B, 0x8232C239}, {0x411C, 0x8232C330}, {0x411D, 0x8232C331}, {0x411E, 0x8232C332}, {0x411F, 0x8232C333}, {0x4120, 0x8232C334}, {0x4121, 0x8232C335}, {0x4122, 0x8232C336}, {0x4123, 0x8232C337}, {0x4124, 0x8232C338}, {0x4125, 0x8232C339}, {0x4126, 0x8232C430}, {0x4127, 0x8232C431}, {0x4128, 0x8232C432}, {0x4129, 0x8232C433}, {0x412A, 0x8232C434}, {0x412B, 0x8232C435}, {0x412C, 0x8232C436}, {0x412D, 0x8232C437}, {0x412E, 0x8232C438}, {0x412F, 0x8232C439}, {0x4130, 0x8232C530}, {0x4131, 0x8232C531}, {0x4132, 0x8232C532}, {0x4133, 0x8232C533}, {0x4134, 0x8232C534}, {0x4135, 0x8232C535}, {0x4136, 0x8232C536}, {0x4137, 0x8232C537}, {0x4138, 0x8232C538}, {0x4139, 0x8232C539}, {0x413A, 0x8232C630}, {0x413B, 0x8232C631}, {0x413C, 0x8232C632}, {0x413D, 0x8232C633}, {0x413E, 0x8232C634}, {0x413F, 0x8232C635}, {0x4140, 0x8232C636}, {0x4141, 0x8232C637}, {0x4142, 0x8232C638}, {0x4143, 0x8232C639}, {0x4144, 0x8232C730}, {0x4145, 0x8232C731}, {0x4146, 0x8232C732}, {0x4147, 0x8232C733}, {0x4148, 0x8232C734}, {0x4149, 0x8232C735}, {0x414A, 0x8232C736}, {0x414B, 0x8232C737}, {0x414C, 0x8232C738}, {0x414D, 0x8232C739}, {0x414E, 0x8232C830}, {0x414F, 0x8232C831}, {0x4150, 0x8232C832}, {0x4151, 0x8232C833}, {0x4152, 0x8232C834}, {0x4153, 0x8232C835}, {0x4154, 0x8232C836}, {0x4155, 0x8232C837}, {0x4156, 0x8232C838}, {0x4157, 0x8232C839}, {0x4158, 0x8232C930}, {0x4159, 0x8232C931}, {0x415A, 0x8232C932}, {0x415B, 0x8232C933}, {0x415C, 0x8232C934}, {0x415D, 0x8232C935}, {0x415E, 0x8232C936}, {0x4338, 0x8232F838}, {0x4339, 0x8232F839}, {0x433A, 0x8232F930}, {0x433B, 0x8232F931}, {0x433C, 0x8232F932}, {0x433D, 0x8232F933}, {0x433E, 0x8232F934}, {0x433F, 0x8232F935}, {0x4340, 0x8232F936}, {0x4341, 0x8232F937}, {0x4342, 0x8232F938}, {0x4343, 0x8232F939}, {0x4344, 0x8232FA30}, {0x4345, 0x8232FA31}, {0x4346, 0x8232FA32}, {0x4347, 0x8232FA33}, {0x4348, 0x8232FA34}, {0x4349, 0x8232FA35}, {0x434A, 0x8232FA36}, {0x434B, 0x8232FA37}, {0x434C, 0x8232FA38}, {0x434D, 0x8232FA39}, {0x434E, 0x8232FB30}, {0x434F, 0x8232FB31}, {0x4350, 0x8232FB32}, {0x4351, 0x8232FB33}, {0x4352, 0x8232FB34}, {0x4353, 0x8232FB35}, {0x4354, 0x8232FB36}, {0x4355, 0x8232FB37}, {0x4356, 0x8232FB38}, {0x4357, 0x8232FB39}, {0x4358, 0x8232FC30}, {0x4359, 0x8232FC31}, {0x435A, 0x8232FC32}, {0x435B, 0x8232FC33}, {0x435C, 0x8232FC34}, {0x435D, 0x8232FC35}, {0x435E, 0x8232FC36}, {0x435F, 0x8232FC37}, {0x4360, 0x8232FC38}, {0x4361, 0x8232FC39}, {0x4362, 0x8232FD30}, {0x4363, 0x8232FD31}, {0x4364, 0x8232FD32}, {0x4365, 0x8232FD33}, {0x4366, 0x8232FD34}, {0x4367, 0x8232FD35}, {0x4368, 0x8232FD36}, {0x4369, 0x8232FD37}, {0x436A, 0x8232FD38}, {0x436B, 0x8232FD39}, {0x436C, 0x8232FE30}, {0x436D, 0x8232FE31}, {0x436E, 0x8232FE32}, {0x436F, 0x8232FE33}, {0x4370, 0x8232FE34}, {0x4371, 0x8232FE35}, {0x4372, 0x8232FE36}, {0x4373, 0x8232FE37}, {0x4374, 0x8232FE38}, {0x4375, 0x8232FE39}, {0x4376, 0x82338130}, {0x4377, 0x82338131}, {0x4378, 0x82338132}, {0x4379, 0x82338133}, {0x437A, 0x82338134}, {0x437B, 0x82338135}, {0x437C, 0x82338136}, {0x437D, 0x82338137}, {0x437E, 0x82338138}, {0x437F, 0x82338139}, {0x4380, 0x82338230}, {0x4381, 0x82338231}, {0x4382, 0x82338232}, {0x4383, 0x82338233}, {0x4384, 0x82338234}, {0x4385, 0x82338235}, {0x4386, 0x82338236}, {0x4387, 0x82338237}, {0x4388, 0x82338238}, {0x4389, 0x82338239}, {0x438A, 0x82338330}, {0x438B, 0x82338331}, {0x438C, 0x82338332}, {0x438D, 0x82338333}, {0x438E, 0x82338334}, {0x438F, 0x82338335}, {0x4390, 0x82338336}, {0x4391, 0x82338337}, {0x4392, 0x82338338}, {0x4393, 0x82338339}, {0x4394, 0x82338430}, {0x4395, 0x82338431}, {0x4396, 0x82338432}, {0x4397, 0x82338433}, {0x4398, 0x82338434}, {0x4399, 0x82338435}, {0x439A, 0x82338436}, {0x439B, 0x82338437}, {0x439C, 0x82338438}, {0x439D, 0x82338439}, {0x439E, 0x82338530}, {0x439F, 0x82338531}, {0x43A0, 0x82338532}, {0x43A1, 0x82338533}, {0x43A2, 0x82338534}, {0x43A3, 0x82338535}, {0x43A4, 0x82338536}, {0x43A5, 0x82338537}, {0x43A6, 0x82338538}, {0x43A7, 0x82338539}, {0x43A8, 0x82338630}, {0x43A9, 0x82338631}, {0x43AA, 0x82338632}, {0x43AB, 0x82338633}, {0x43AD, 0x82338634}, {0x43AE, 0x82338635}, {0x43AF, 0x82338636}, {0x43B0, 0x82338637}, {0x43B2, 0x82338638}, {0x43B3, 0x82338639}, {0x43B4, 0x82338730}, {0x43B5, 0x82338731}, {0x43B6, 0x82338732}, {0x43B7, 0x82338733}, {0x43B8, 0x82338734}, {0x43B9, 0x82338735}, {0x43BA, 0x82338736}, {0x43BB, 0x82338737}, {0x43BC, 0x82338738}, {0x43BD, 0x82338739}, {0x43BE, 0x82338830}, {0x43BF, 0x82338831}, {0x43C0, 0x82338832}, {0x43C1, 0x82338833}, {0x43C2, 0x82338834}, {0x43C3, 0x82338835}, {0x43C4, 0x82338836}, {0x43C5, 0x82338837}, {0x43C6, 0x82338838}, {0x43C7, 0x82338839}, {0x43C8, 0x82338930}, {0x43C9, 0x82338931}, {0x43CA, 0x82338932}, {0x43CB, 0x82338933}, {0x43CC, 0x82338934}, {0x43CD, 0x82338935}, {0x43CE, 0x82338936}, {0x43CF, 0x82338937}, {0x43D0, 0x82338938}, {0x43D1, 0x82338939}, {0x43D2, 0x82338A30}, {0x43D3, 0x82338A31}, {0x43D4, 0x82338A32}, {0x43D5, 0x82338A33}, {0x43D6, 0x82338A34}, {0x43D7, 0x82338A35}, {0x43D8, 0x82338A36}, {0x43D9, 0x82338A37}, {0x43DA, 0x82338A38}, {0x43DB, 0x82338A39}, {0x43DC, 0x82338B30}, {0x43DE, 0x82338B31}, {0x43DF, 0x82338B32}, {0x43E0, 0x82338B33}, {0x43E1, 0x82338B34}, {0x43E2, 0x82338B35}, {0x43E3, 0x82338B36}, {0x43E4, 0x82338B37}, {0x43E5, 0x82338B38}, {0x43E6, 0x82338B39}, {0x43E7, 0x82338C30}, {0x43E8, 0x82338C31}, {0x43E9, 0x82338C32}, {0x43EA, 0x82338C33}, {0x43EB, 0x82338C34}, {0x43EC, 0x82338C35}, {0x43ED, 0x82338C36}, {0x43EE, 0x82338C37}, {0x43EF, 0x82338C38}, {0x43F0, 0x82338C39}, {0x43F1, 0x82338D30}, {0x43F2, 0x82338D31}, {0x43F3, 0x82338D32}, {0x43F4, 0x82338D33}, {0x43F5, 0x82338D34}, {0x43F6, 0x82338D35}, {0x43F7, 0x82338D36}, {0x43F8, 0x82338D37}, {0x43F9, 0x82338D38}, {0x43FA, 0x82338D39}, {0x43FB, 0x82338E30}, {0x43FC, 0x82338E31}, {0x43FD, 0x82338E32}, {0x43FE, 0x82338E33}, {0x43FF, 0x82338E34}, {0x4400, 0x82338E35}, {0x4401, 0x82338E36}, {0x4402, 0x82338E37}, {0x4403, 0x82338E38}, {0x4404, 0x82338E39}, {0x4405, 0x82338F30}, {0x4406, 0x82338F31}, {0x4407, 0x82338F32}, {0x4408, 0x82338F33}, {0x4409, 0x82338F34}, {0x440A, 0x82338F35}, {0x440B, 0x82338F36}, {0x440C, 0x82338F37}, {0x440D, 0x82338F38}, {0x440E, 0x82338F39}, {0x440F, 0x82339030}, {0x4410, 0x82339031}, {0x4411, 0x82339032}, {0x4412, 0x82339033}, {0x4413, 0x82339034}, {0x4414, 0x82339035}, {0x4415, 0x82339036}, {0x4416, 0x82339037}, {0x4417, 0x82339038}, {0x4418, 0x82339039}, {0x4419, 0x82339130}, {0x441A, 0x82339131}, {0x441B, 0x82339132}, {0x441C, 0x82339133}, {0x441D, 0x82339134}, {0x441E, 0x82339135}, {0x441F, 0x82339136}, {0x4420, 0x82339137}, {0x4421, 0x82339138}, {0x4422, 0x82339139}, {0x4423, 0x82339230}, {0x4424, 0x82339231}, {0x4425, 0x82339232}, {0x4426, 0x82339233}, {0x4427, 0x82339234}, {0x4428, 0x82339235}, {0x4429, 0x82339236}, {0x442A, 0x82339237}, {0x442B, 0x82339238}, {0x442C, 0x82339239}, {0x442D, 0x82339330}, {0x442E, 0x82339331}, {0x442F, 0x82339332}, {0x4430, 0x82339333}, {0x4431, 0x82339334}, {0x4432, 0x82339335}, {0x4433, 0x82339336}, {0x4434, 0x82339337}, {0x4435, 0x82339338}, {0x4436, 0x82339339}, {0x4437, 0x82339430}, {0x4438, 0x82339431}, {0x4439, 0x82339432}, {0x443A, 0x82339433}, {0x443B, 0x82339434}, {0x443C, 0x82339435}, {0x443D, 0x82339436}, {0x443E, 0x82339437}, {0x443F, 0x82339438}, {0x4440, 0x82339439}, {0x4441, 0x82339530}, {0x4442, 0x82339531}, {0x4443, 0x82339532}, {0x4444, 0x82339533}, {0x4445, 0x82339534}, {0x4446, 0x82339535}, {0x4447, 0x82339536}, {0x4448, 0x82339537}, {0x4449, 0x82339538}, {0x444A, 0x82339539}, {0x444B, 0x82339630}, {0x444C, 0x82339631}, {0x444D, 0x82339632}, {0x444E, 0x82339633}, {0x444F, 0x82339634}, {0x4450, 0x82339635}, {0x4451, 0x82339636}, {0x4452, 0x82339637}, {0x4453, 0x82339638}, {0x4454, 0x82339639}, {0x4455, 0x82339730}, {0x4456, 0x82339731}, {0x4457, 0x82339732}, {0x4458, 0x82339733}, {0x4459, 0x82339734}, {0x445A, 0x82339735}, {0x445B, 0x82339736}, {0x445C, 0x82339737}, {0x445D, 0x82339738}, {0x445E, 0x82339739}, {0x445F, 0x82339830}, {0x4460, 0x82339831}, {0x4461, 0x82339832}, {0x4462, 0x82339833}, {0x4463, 0x82339834}, {0x4464, 0x82339835}, {0x4465, 0x82339836}, {0x4466, 0x82339837}, {0x4467, 0x82339838}, {0x4468, 0x82339839}, {0x4469, 0x82339930}, {0x446A, 0x82339931}, {0x446B, 0x82339932}, {0x446C, 0x82339933}, {0x446D, 0x82339934}, {0x446E, 0x82339935}, {0x446F, 0x82339936}, {0x4470, 0x82339937}, {0x4471, 0x82339938}, {0x4472, 0x82339939}, {0x4473, 0x82339A30}, {0x4474, 0x82339A31}, {0x4475, 0x82339A32}, {0x4476, 0x82339A33}, {0x4477, 0x82339A34}, {0x4478, 0x82339A35}, {0x4479, 0x82339A36}, {0x447A, 0x82339A37}, {0x447B, 0x82339A38}, {0x447C, 0x82339A39}, {0x447D, 0x82339B30}, {0x447E, 0x82339B31}, {0x447F, 0x82339B32}, {0x4480, 0x82339B33}, {0x4481, 0x82339B34}, {0x4482, 0x82339B35}, {0x4483, 0x82339B36}, {0x4484, 0x82339B37}, {0x4485, 0x82339B38}, {0x4486, 0x82339B39}, {0x4487, 0x82339C30}, {0x4488, 0x82339C31}, {0x4489, 0x82339C32}, {0x448A, 0x82339C33}, {0x448B, 0x82339C34}, {0x448C, 0x82339C35}, {0x448D, 0x82339C36}, {0x448E, 0x82339C37}, {0x448F, 0x82339C38}, {0x4490, 0x82339C39}, {0x4491, 0x82339D30}, {0x4492, 0x82339D31}, {0x4493, 0x82339D32}, {0x4494, 0x82339D33}, {0x4495, 0x82339D34}, {0x4496, 0x82339D35}, {0x4497, 0x82339D36}, {0x4498, 0x82339D37}, {0x4499, 0x82339D38}, {0x449A, 0x82339D39}, {0x449B, 0x82339E30}, {0x449C, 0x82339E31}, {0x449D, 0x82339E32}, {0x449E, 0x82339E33}, {0x449F, 0x82339E34}, {0x44A0, 0x82339E35}, {0x44A1, 0x82339E36}, {0x44A2, 0x82339E37}, {0x44A3, 0x82339E38}, {0x44A4, 0x82339E39}, {0x44A5, 0x82339F30}, {0x44A6, 0x82339F31}, {0x44A7, 0x82339F32}, {0x44A8, 0x82339F33}, {0x44A9, 0x82339F34}, {0x44AA, 0x82339F35}, {0x44AB, 0x82339F36}, {0x44AC, 0x82339F37}, {0x44AD, 0x82339F38}, {0x44AE, 0x82339F39}, {0x44AF, 0x8233A030}, {0x44B0, 0x8233A031}, {0x44B1, 0x8233A032}, {0x44B2, 0x8233A033}, {0x44B3, 0x8233A034}, {0x44B4, 0x8233A035}, {0x44B5, 0x8233A036}, {0x44B6, 0x8233A037}, {0x44B7, 0x8233A038}, {0x44B8, 0x8233A039}, {0x44B9, 0x8233A130}, {0x44BA, 0x8233A131}, {0x44BB, 0x8233A132}, {0x44BC, 0x8233A133}, {0x44BD, 0x8233A134}, {0x44BE, 0x8233A135}, {0x44BF, 0x8233A136}, {0x44C0, 0x8233A137}, {0x44C1, 0x8233A138}, {0x44C2, 0x8233A139}, {0x44C3, 0x8233A230}, {0x44C4, 0x8233A231}, {0x44C5, 0x8233A232}, {0x44C6, 0x8233A233}, {0x44C7, 0x8233A234}, {0x44C8, 0x8233A235}, {0x44C9, 0x8233A236}, {0x44CA, 0x8233A237}, {0x44CB, 0x8233A238}, {0x44CC, 0x8233A239}, {0x44CD, 0x8233A330}, {0x44CE, 0x8233A331}, {0x44CF, 0x8233A332}, {0x44D0, 0x8233A333}, {0x44D1, 0x8233A334}, {0x44D2, 0x8233A335}, {0x44D3, 0x8233A336}, {0x44D4, 0x8233A337}, {0x44D5, 0x8233A338}, {0x464D, 0x8233C932}, {0x464E, 0x8233C933}, {0x464F, 0x8233C934}, {0x4650, 0x8233C935}, {0x4651, 0x8233C936}, {0x4652, 0x8233C937}, {0x4653, 0x8233C938}, {0x4654, 0x8233C939}, {0x4655, 0x8233CA30}, {0x4656, 0x8233CA31}, {0x4657, 0x8233CA32}, {0x4658, 0x8233CA33}, {0x4659, 0x8233CA34}, {0x465A, 0x8233CA35}, {0x465B, 0x8233CA36}, {0x465C, 0x8233CA37}, {0x465D, 0x8233CA38}, {0x465E, 0x8233CA39}, {0x465F, 0x8233CB30}, {0x4660, 0x8233CB31}, {0x4662, 0x8233CB32}, {0x4663, 0x8233CB33}, {0x4664, 0x8233CB34}, {0x4665, 0x8233CB35}, {0x4666, 0x8233CB36}, {0x4667, 0x8233CB37}, {0x4668, 0x8233CB38}, {0x4669, 0x8233CB39}, {0x466A, 0x8233CC30}, {0x466B, 0x8233CC31}, {0x466C, 0x8233CC32}, {0x466D, 0x8233CC33}, {0x466E, 0x8233CC34}, {0x466F, 0x8233CC35}, {0x4670, 0x8233CC36}, {0x4671, 0x8233CC37}, {0x4672, 0x8233CC38}, {0x4673, 0x8233CC39}, {0x4674, 0x8233CD30}, {0x4675, 0x8233CD31}, {0x4676, 0x8233CD32}, {0x4677, 0x8233CD33}, {0x4678, 0x8233CD34}, {0x4679, 0x8233CD35}, {0x467A, 0x8233CD36}, {0x467B, 0x8233CD37}, {0x467C, 0x8233CD38}, {0x467D, 0x8233CD39}, {0x467E, 0x8233CE30}, {0x467F, 0x8233CE31}, {0x4680, 0x8233CE32}, {0x4681, 0x8233CE33}, {0x4682, 0x8233CE34}, {0x4683, 0x8233CE35}, {0x4684, 0x8233CE36}, {0x4685, 0x8233CE37}, {0x4686, 0x8233CE38}, {0x4687, 0x8233CE39}, {0x4688, 0x8233CF30}, {0x4689, 0x8233CF31}, {0x468A, 0x8233CF32}, {0x468B, 0x8233CF33}, {0x468C, 0x8233CF34}, {0x468D, 0x8233CF35}, {0x468E, 0x8233CF36}, {0x468F, 0x8233CF37}, {0x4690, 0x8233CF38}, {0x4691, 0x8233CF39}, {0x4692, 0x8233D030}, {0x4693, 0x8233D031}, {0x4694, 0x8233D032}, {0x4695, 0x8233D033}, {0x4696, 0x8233D034}, {0x4697, 0x8233D035}, {0x4698, 0x8233D036}, {0x4699, 0x8233D037}, {0x469A, 0x8233D038}, {0x469B, 0x8233D039}, {0x469C, 0x8233D130}, {0x469D, 0x8233D131}, {0x469E, 0x8233D132}, {0x469F, 0x8233D133}, {0x46A0, 0x8233D134}, {0x46A1, 0x8233D135}, {0x46A2, 0x8233D136}, {0x46A3, 0x8233D137}, {0x46A4, 0x8233D138}, {0x46A5, 0x8233D139}, {0x46A6, 0x8233D230}, {0x46A7, 0x8233D231}, {0x46A8, 0x8233D232}, {0x46A9, 0x8233D233}, {0x46AA, 0x8233D234}, {0x46AB, 0x8233D235}, {0x46AC, 0x8233D236}, {0x46AD, 0x8233D237}, {0x46AE, 0x8233D238}, {0x46AF, 0x8233D239}, {0x46B0, 0x8233D330}, {0x46B1, 0x8233D331}, {0x46B2, 0x8233D332}, {0x46B3, 0x8233D333}, {0x46B4, 0x8233D334}, {0x46B5, 0x8233D335}, {0x46B6, 0x8233D336}, {0x46B7, 0x8233D337}, {0x46B8, 0x8233D338}, {0x46B9, 0x8233D339}, {0x46BA, 0x8233D430}, {0x46BB, 0x8233D431}, {0x46BC, 0x8233D432}, {0x46BD, 0x8233D433}, {0x46BE, 0x8233D434}, {0x46BF, 0x8233D435}, {0x46C0, 0x8233D436}, {0x46C1, 0x8233D437}, {0x46C2, 0x8233D438}, {0x46C3, 0x8233D439}, {0x46C4, 0x8233D530}, {0x46C5, 0x8233D531}, {0x46C6, 0x8233D532}, {0x46C7, 0x8233D533}, {0x46C8, 0x8233D534}, {0x46C9, 0x8233D535}, {0x46CA, 0x8233D536}, {0x46CB, 0x8233D537}, {0x46CC, 0x8233D538}, {0x46CD, 0x8233D539}, {0x46CE, 0x8233D630}, {0x46CF, 0x8233D631}, {0x46D0, 0x8233D632}, {0x46D1, 0x8233D633}, {0x46D2, 0x8233D634}, {0x46D3, 0x8233D635}, {0x46D4, 0x8233D636}, {0x46D5, 0x8233D637}, {0x46D6, 0x8233D638}, {0x46D7, 0x8233D639}, {0x46D8, 0x8233D730}, {0x46D9, 0x8233D731}, {0x46DA, 0x8233D732}, {0x46DB, 0x8233D733}, {0x46DC, 0x8233D734}, {0x46DD, 0x8233D735}, {0x46DE, 0x8233D736}, {0x46DF, 0x8233D737}, {0x46E0, 0x8233D738}, {0x46E1, 0x8233D739}, {0x46E2, 0x8233D830}, {0x46E3, 0x8233D831}, {0x46E4, 0x8233D832}, {0x46E5, 0x8233D833}, {0x46E6, 0x8233D834}, {0x46E7, 0x8233D835}, {0x46E8, 0x8233D836}, {0x46E9, 0x8233D837}, {0x46EA, 0x8233D838}, {0x46EB, 0x8233D839}, {0x46EC, 0x8233D930}, {0x46ED, 0x8233D931}, {0x46EE, 0x8233D932}, {0x46EF, 0x8233D933}, {0x46F0, 0x8233D934}, {0x46F1, 0x8233D935}, {0x46F2, 0x8233D936}, {0x46F3, 0x8233D937}, {0x46F4, 0x8233D938}, {0x46F5, 0x8233D939}, {0x46F6, 0x8233DA30}, {0x46F7, 0x8233DA31}, {0x46F8, 0x8233DA32}, {0x46F9, 0x8233DA33}, {0x46FA, 0x8233DA34}, {0x46FB, 0x8233DA35}, {0x46FC, 0x8233DA36}, {0x46FD, 0x8233DA37}, {0x46FE, 0x8233DA38}, {0x46FF, 0x8233DA39}, {0x4700, 0x8233DB30}, {0x4701, 0x8233DB31}, {0x4702, 0x8233DB32}, {0x4703, 0x8233DB33}, {0x4704, 0x8233DB34}, {0x4705, 0x8233DB35}, {0x4706, 0x8233DB36}, {0x4707, 0x8233DB37}, {0x4708, 0x8233DB38}, {0x4709, 0x8233DB39}, {0x470A, 0x8233DC30}, {0x470B, 0x8233DC31}, {0x470C, 0x8233DC32}, {0x470D, 0x8233DC33}, {0x470E, 0x8233DC34}, {0x470F, 0x8233DC35}, {0x4710, 0x8233DC36}, {0x4711, 0x8233DC37}, {0x4712, 0x8233DC38}, {0x4713, 0x8233DC39}, {0x4714, 0x8233DD30}, {0x4715, 0x8233DD31}, {0x4716, 0x8233DD32}, {0x4717, 0x8233DD33}, {0x4718, 0x8233DD34}, {0x4719, 0x8233DD35}, {0x471A, 0x8233DD36}, {0x471B, 0x8233DD37}, {0x471C, 0x8233DD38}, {0x471D, 0x8233DD39}, {0x471E, 0x8233DE30}, {0x471F, 0x8233DE31}, {0x4720, 0x8233DE32}, {0x4721, 0x8233DE33}, {0x4722, 0x8233DE34}, {0x4724, 0x8233DE35}, {0x4725, 0x8233DE36}, {0x4726, 0x8233DE37}, {0x4727, 0x8233DE38}, {0x4728, 0x8233DE39}, {0x472A, 0x8233DF30}, {0x472B, 0x8233DF31}, {0x472C, 0x8233DF32}, {0x472D, 0x8233DF33}, {0x472E, 0x8233DF34}, {0x472F, 0x8233DF35}, {0x4730, 0x8233DF36}, {0x4731, 0x8233DF37}, {0x4732, 0x8233DF38}, {0x4733, 0x8233DF39}, {0x4734, 0x8233E030}, {0x4735, 0x8233E031}, {0x4736, 0x8233E032}, {0x4737, 0x8233E033}, {0x4738, 0x8233E034}, {0x4739, 0x8233E035}, {0x473A, 0x8233E036}, {0x473B, 0x8233E037}, {0x473C, 0x8233E038}, {0x473D, 0x8233E039}, {0x473E, 0x8233E130}, {0x473F, 0x8233E131}, {0x4740, 0x8233E132}, {0x4741, 0x8233E133}, {0x4742, 0x8233E134}, {0x4743, 0x8233E135}, {0x4744, 0x8233E136}, {0x4745, 0x8233E137}, {0x4746, 0x8233E138}, {0x4747, 0x8233E139}, {0x4748, 0x8233E230}, {0x4749, 0x8233E231}, {0x474A, 0x8233E232}, {0x474B, 0x8233E233}, {0x474C, 0x8233E234}, {0x474D, 0x8233E235}, {0x474E, 0x8233E236}, {0x474F, 0x8233E237}, {0x4750, 0x8233E238}, {0x4751, 0x8233E239}, {0x4752, 0x8233E330}, {0x4753, 0x8233E331}, {0x4754, 0x8233E332}, {0x4755, 0x8233E333}, {0x4756, 0x8233E334}, {0x4757, 0x8233E335}, {0x4758, 0x8233E336}, {0x4759, 0x8233E337}, {0x475A, 0x8233E338}, {0x475B, 0x8233E339}, {0x475C, 0x8233E430}, {0x475D, 0x8233E431}, {0x475E, 0x8233E432}, {0x475F, 0x8233E433}, {0x4760, 0x8233E434}, {0x4761, 0x8233E435}, {0x4762, 0x8233E436}, {0x4763, 0x8233E437}, {0x4764, 0x8233E438}, {0x4765, 0x8233E439}, {0x4766, 0x8233E530}, {0x4767, 0x8233E531}, {0x4768, 0x8233E532}, {0x4769, 0x8233E533}, {0x476A, 0x8233E534}, {0x476B, 0x8233E535}, {0x476C, 0x8233E536}, {0x476D, 0x8233E537}, {0x476E, 0x8233E538}, {0x476F, 0x8233E539}, {0x4770, 0x8233E630}, {0x4771, 0x8233E631}, {0x4772, 0x8233E632}, {0x4773, 0x8233E633}, {0x4774, 0x8233E634}, {0x4775, 0x8233E635}, {0x4776, 0x8233E636}, {0x4777, 0x8233E637}, {0x4778, 0x8233E638}, {0x4779, 0x8233E639}, {0x477A, 0x8233E730}, {0x477B, 0x8233E731}, {0x477D, 0x8233E732}, {0x477E, 0x8233E733}, {0x477F, 0x8233E734}, {0x4780, 0x8233E735}, {0x4781, 0x8233E736}, {0x4782, 0x8233E737}, {0x4783, 0x8233E738}, {0x4784, 0x8233E739}, {0x4785, 0x8233E830}, {0x4786, 0x8233E831}, {0x4787, 0x8233E832}, {0x4788, 0x8233E833}, {0x4789, 0x8233E834}, {0x478A, 0x8233E835}, {0x478B, 0x8233E836}, {0x478C, 0x8233E837}, {0x4948, 0x82349639}, {0x4949, 0x82349730}, {0x494A, 0x82349731}, {0x494B, 0x82349732}, {0x494C, 0x82349733}, {0x494D, 0x82349734}, {0x494E, 0x82349735}, {0x494F, 0x82349736}, {0x4950, 0x82349737}, {0x4951, 0x82349738}, {0x4952, 0x82349739}, {0x4953, 0x82349830}, {0x4954, 0x82349831}, {0x4955, 0x82349832}, {0x4956, 0x82349833}, {0x4957, 0x82349834}, {0x4958, 0x82349835}, {0x4959, 0x82349836}, {0x495A, 0x82349837}, {0x495B, 0x82349838}, {0x495C, 0x82349839}, {0x495D, 0x82349930}, {0x495E, 0x82349931}, {0x495F, 0x82349932}, {0x4960, 0x82349933}, {0x4961, 0x82349934}, {0x4962, 0x82349935}, {0x4963, 0x82349936}, {0x4964, 0x82349937}, {0x4965, 0x82349938}, {0x4966, 0x82349939}, {0x4967, 0x82349A30}, {0x4968, 0x82349A31}, {0x4969, 0x82349A32}, {0x496A, 0x82349A33}, {0x496B, 0x82349A34}, {0x496C, 0x82349A35}, {0x496D, 0x82349A36}, {0x496E, 0x82349A37}, {0x496F, 0x82349A38}, {0x4970, 0x82349A39}, {0x4971, 0x82349B30}, {0x4972, 0x82349B31}, {0x4973, 0x82349B32}, {0x4974, 0x82349B33}, {0x4975, 0x82349B34}, {0x4976, 0x82349B35}, {0x4977, 0x82349B36}, {0x4978, 0x82349B37}, {0x4979, 0x82349B38}, {0x497B, 0x82349B39}, {0x497C, 0x82349C30}, {0x497E, 0x82349C31}, {0x497F, 0x82349C32}, {0x4980, 0x82349C33}, {0x4981, 0x82349C34}, {0x4984, 0x82349C35}, {0x4987, 0x82349C36}, {0x4988, 0x82349C37}, {0x4989, 0x82349C38}, {0x498A, 0x82349C39}, {0x498B, 0x82349D30}, {0x498C, 0x82349D31}, {0x498D, 0x82349D32}, {0x498E, 0x82349D33}, {0x498F, 0x82349D34}, {0x4990, 0x82349D35}, {0x4991, 0x82349D36}, {0x4992, 0x82349D37}, {0x4993, 0x82349D38}, {0x4994, 0x82349D39}, {0x4995, 0x82349E30}, {0x4996, 0x82349E31}, {0x4997, 0x82349E32}, {0x4998, 0x82349E33}, {0x4999, 0x82349E34}, {0x499A, 0x82349E35}, {0x499C, 0x82349E36}, {0x499D, 0x82349E37}, {0x499E, 0x82349E38}, {0x49A0, 0x82349E39}, {0x49A1, 0x82349F30}, {0x49A2, 0x82349F31}, {0x49A3, 0x82349F32}, {0x49A4, 0x82349F33}, {0x49A5, 0x82349F34}, {0x49A6, 0x82349F35}, {0x49A7, 0x82349F36}, {0x49A8, 0x82349F37}, {0x49A9, 0x82349F38}, {0x49AA, 0x82349F39}, {0x49AB, 0x8234A030}, {0x49AC, 0x8234A031}, {0x49AD, 0x8234A032}, {0x49AE, 0x8234A033}, {0x49AF, 0x8234A034}, {0x49B0, 0x8234A035}, {0x49B1, 0x8234A036}, {0x49B2, 0x8234A037}, {0x49B3, 0x8234A038}, {0x49B4, 0x8234A039}, {0x49B5, 0x8234A130}, {0x4C78, 0x8234E734}, {0x4C79, 0x8234E735}, {0x4C7A, 0x8234E736}, {0x4C7B, 0x8234E737}, {0x4C7C, 0x8234E738}, {0x4C7D, 0x8234E739}, {0x4C7E, 0x8234E830}, {0x4C7F, 0x8234E831}, {0x4C80, 0x8234E832}, {0x4C81, 0x8234E833}, {0x4C82, 0x8234E834}, {0x4C83, 0x8234E835}, {0x4C84, 0x8234E836}, {0x4C85, 0x8234E837}, {0x4C86, 0x8234E838}, {0x4C87, 0x8234E839}, {0x4C88, 0x8234E930}, {0x4C89, 0x8234E931}, {0x4C8A, 0x8234E932}, {0x4C8B, 0x8234E933}, {0x4C8C, 0x8234E934}, {0x4C8D, 0x8234E935}, {0x4C8E, 0x8234E936}, {0x4C8F, 0x8234E937}, {0x4C90, 0x8234E938}, {0x4C91, 0x8234E939}, {0x4C92, 0x8234EA30}, {0x4C93, 0x8234EA31}, {0x4C94, 0x8234EA32}, {0x4C95, 0x8234EA33}, {0x4C96, 0x8234EA34}, {0x4C97, 0x8234EA35}, {0x4C98, 0x8234EA36}, {0x4C99, 0x8234EA37}, {0x4C9A, 0x8234EA38}, {0x4C9B, 0x8234EA39}, {0x4C9C, 0x8234EB30}, {0x4C9D, 0x8234EB31}, {0x4C9E, 0x8234EB32}, {0x4CA4, 0x8234EB33}, {0x4CA5, 0x8234EB34}, {0x4CA6, 0x8234EB35}, {0x4CA7, 0x8234EB36}, {0x4CA8, 0x8234EB37}, {0x4CA9, 0x8234EB38}, {0x4CAA, 0x8234EB39}, {0x4CAB, 0x8234EC30}, {0x4CAC, 0x8234EC31}, {0x4CAD, 0x8234EC32}, {0x4CAE, 0x8234EC33}, {0x4CAF, 0x8234EC34}, {0x4CB0, 0x8234EC35}, {0x4CB1, 0x8234EC36}, {0x4CB2, 0x8234EC37}, {0x4CB3, 0x8234EC38}, {0x4CB4, 0x8234EC39}, {0x4CB5, 0x8234ED30}, {0x4CB6, 0x8234ED31}, {0x4CB7, 0x8234ED32}, {0x4CB8, 0x8234ED33}, {0x4CB9, 0x8234ED34}, {0x4CBA, 0x8234ED35}, {0x4CBB, 0x8234ED36}, {0x4CBC, 0x8234ED37}, {0x4CBD, 0x8234ED38}, {0x4CBE, 0x8234ED39}, {0x4CBF, 0x8234EE30}, {0x4CC0, 0x8234EE31}, {0x4CC1, 0x8234EE32}, {0x4CC2, 0x8234EE33}, {0x4CC3, 0x8234EE34}, {0x4CC4, 0x8234EE35}, {0x4CC5, 0x8234EE36}, {0x4CC6, 0x8234EE37}, {0x4CC7, 0x8234EE38}, {0x4CC8, 0x8234EE39}, {0x4CC9, 0x8234EF30}, {0x4CCA, 0x8234EF31}, {0x4CCB, 0x8234EF32}, {0x4CCC, 0x8234EF33}, {0x4CCD, 0x8234EF34}, {0x4CCE, 0x8234EF35}, {0x4CCF, 0x8234EF36}, {0x4CD0, 0x8234EF37}, {0x4CD1, 0x8234EF38}, {0x4CD2, 0x8234EF39}, {0x4CD3, 0x8234F030}, {0x4CD4, 0x8234F031}, {0x4CD5, 0x8234F032}, {0x4CD6, 0x8234F033}, {0x4CD7, 0x8234F034}, {0x4CD8, 0x8234F035}, {0x4CD9, 0x8234F036}, {0x4CDA, 0x8234F037}, {0x4CDB, 0x8234F038}, {0x4CDC, 0x8234F039}, {0x4CDD, 0x8234F130}, {0x4CDE, 0x8234F131}, {0x4CDF, 0x8234F132}, {0x4CE0, 0x8234F133}, {0x4CE1, 0x8234F134}, {0x4CE2, 0x8234F135}, {0x4CE3, 0x8234F136}, {0x4CE4, 0x8234F137}, {0x4CE5, 0x8234F138}, {0x4CE6, 0x8234F139}, {0x4CE7, 0x8234F230}, {0x4CE8, 0x8234F231}, {0x4CE9, 0x8234F232}, {0x4CEA, 0x8234F233}, {0x4CEB, 0x8234F234}, {0x4CEC, 0x8234F235}, {0x4CED, 0x8234F236}, {0x4CEE, 0x8234F237}, {0x4CEF, 0x8234F238}, {0x4CF0, 0x8234F239}, {0x4CF1, 0x8234F330}, {0x4CF2, 0x8234F331}, {0x4CF3, 0x8234F332}, {0x4CF4, 0x8234F333}, {0x4CF5, 0x8234F334}, {0x4CF6, 0x8234F335}, {0x4CF7, 0x8234F336}, {0x4CF8, 0x8234F337}, {0x4CF9, 0x8234F338}, {0x4CFA, 0x8234F339}, {0x4CFB, 0x8234F430}, {0x4CFC, 0x8234F431}, {0x4CFD, 0x8234F432}, {0x4CFE, 0x8234F433}, {0x4CFF, 0x8234F434}, {0x4D00, 0x8234F435}, {0x4D01, 0x8234F436}, {0x4D02, 0x8234F437}, {0x4D03, 0x8234F438}, {0x4D04, 0x8234F439}, {0x4D05, 0x8234F530}, {0x4D06, 0x8234F531}, {0x4D07, 0x8234F532}, {0x4D08, 0x8234F533}, {0x4D09, 0x8234F534}, {0x4D0A, 0x8234F535}, {0x4D0B, 0x8234F536}, {0x4D0C, 0x8234F537}, {0x4D0D, 0x8234F538}, {0x4D0E, 0x8234F539}, {0x4D0F, 0x8234F630}, {0x4D10, 0x8234F631}, {0x4D11, 0x8234F632}, {0x4D12, 0x8234F633}, {0x4D1A, 0x8234F634}, {0x4D1B, 0x8234F635}, {0x4D1C, 0x8234F636}, {0x4D1D, 0x8234F637}, {0x4D1E, 0x8234F638}, {0x4D1F, 0x8234F639}, {0x4D20, 0x8234F730}, {0x4D21, 0x8234F731}, {0x4D22, 0x8234F732}, {0x4D23, 0x8234F733}, {0x4D24, 0x8234F734}, {0x4D25, 0x8234F735}, {0x4D26, 0x8234F736}, {0x4D27, 0x8234F737}, {0x4D28, 0x8234F738}, {0x4D29, 0x8234F739}, {0x4D2A, 0x8234F830}, {0x4D2B, 0x8234F831}, {0x4D2C, 0x8234F832}, {0x4D2D, 0x8234F833}, {0x4D2E, 0x8234F834}, {0x4D2F, 0x8234F835}, {0x4D30, 0x8234F836}, {0x4D31, 0x8234F837}, {0x4D32, 0x8234F838}, {0x4D33, 0x8234F839}, {0x4D34, 0x8234F930}, {0x4D35, 0x8234F931}, {0x4D36, 0x8234F932}, {0x4D37, 0x8234F933}, {0x4D38, 0x8234F934}, {0x4D39, 0x8234F935}, {0x4D3A, 0x8234F936}, {0x4D3B, 0x8234F937}, {0x4D3C, 0x8234F938}, {0x4D3D, 0x8234F939}, {0x4D3E, 0x8234FA30}, {0x4D3F, 0x8234FA31}, {0x4D40, 0x8234FA32}, {0x4D41, 0x8234FA33}, {0x4D42, 0x8234FA34}, {0x4D43, 0x8234FA35}, {0x4D44, 0x8234FA36}, {0x4D45, 0x8234FA37}, {0x4D46, 0x8234FA38}, {0x4D47, 0x8234FA39}, {0x4D48, 0x8234FB30}, {0x4D49, 0x8234FB31}, {0x4D4A, 0x8234FB32}, {0x4D4B, 0x8234FB33}, {0x4D4C, 0x8234FB34}, {0x4D4D, 0x8234FB35}, {0x4D4E, 0x8234FB36}, {0x4D4F, 0x8234FB37}, {0x4D50, 0x8234FB38}, {0x4D51, 0x8234FB39}, {0x4D52, 0x8234FC30}, {0x4D53, 0x8234FC31}, {0x4D54, 0x8234FC32}, {0x4D55, 0x8234FC33}, {0x4D56, 0x8234FC34}, {0x4D57, 0x8234FC35}, {0x4D58, 0x8234FC36}, {0x4D59, 0x8234FC37}, {0x4D5A, 0x8234FC38}, {0x4D5B, 0x8234FC39}, {0x4D5C, 0x8234FD30}, {0x4D5D, 0x8234FD31}, {0x4D5E, 0x8234FD32}, {0x4D5F, 0x8234FD33}, {0x4D60, 0x8234FD34}, {0x4D61, 0x8234FD35}, {0x4D62, 0x8234FD36}, {0x4D63, 0x8234FD37}, {0x4D64, 0x8234FD38}, {0x4D65, 0x8234FD39}, {0x4D66, 0x8234FE30}, {0x4D67, 0x8234FE31}, {0x4D68, 0x8234FE32}, {0x4D69, 0x8234FE33}, {0x4D6A, 0x8234FE34}, {0x4D6B, 0x8234FE35}, {0x4D6C, 0x8234FE36}, {0x4D6D, 0x8234FE37}, {0x4D6E, 0x8234FE38}, {0x4D6F, 0x8234FE39}, {0x4D70, 0x82358130}, {0x4D71, 0x82358131}, {0x4D72, 0x82358132}, {0x4D73, 0x82358133}, {0x4D74, 0x82358134}, {0x4D75, 0x82358135}, {0x4D76, 0x82358136}, {0x4D77, 0x82358137}, {0x4D78, 0x82358138}, {0x4D79, 0x82358139}, {0x4D7A, 0x82358230}, {0x4D7B, 0x82358231}, {0x4D7C, 0x82358232}, {0x4D7D, 0x82358233}, {0x4D7E, 0x82358234}, {0x4D7F, 0x82358235}, {0x4D80, 0x82358236}, {0x4D81, 0x82358237}, {0x4D82, 0x82358238}, {0x4D83, 0x82358239}, {0x4D84, 0x82358330}, {0x4D85, 0x82358331}, {0x4D86, 0x82358332}, {0x4D87, 0x82358333}, {0x4D88, 0x82358334}, {0x4D89, 0x82358335}, {0x4D8A, 0x82358336}, {0x4D8B, 0x82358337}, {0x4D8C, 0x82358338}, {0x4D8D, 0x82358339}, {0x4D8E, 0x82358430}, {0x4D8F, 0x82358431}, {0x4D90, 0x82358432}, {0x4D91, 0x82358433}, {0x4D92, 0x82358434}, {0x4D93, 0x82358435}, {0x4D94, 0x82358436}, {0x4D95, 0x82358437}, {0x4D96, 0x82358438}, {0x4D97, 0x82358439}, {0x4D98, 0x82358530}, {0x4D99, 0x82358531}, {0x4D9A, 0x82358532}, {0x4D9B, 0x82358533}, {0x4D9C, 0x82358534}, {0x4D9D, 0x82358535}, {0x4D9E, 0x82358536}, {0x4D9F, 0x82358537}, {0x4DA0, 0x82358538}, {0x4DA1, 0x82358539}, {0x4DA2, 0x82358630}, {0x4DA3, 0x82358631}, {0x4DA4, 0x82358632}, {0x4DA5, 0x82358633}, {0x4DA6, 0x82358634}, {0x4DA7, 0x82358635}, {0x4DA8, 0x82358636}, {0x4DA9, 0x82358637}, {0x4DAA, 0x82358638}, {0x4DAB, 0x82358639}, {0x4DAC, 0x82358730}, {0x4DAD, 0x82358731}, {0x4DAF, 0x82358732}, {0x4DB0, 0x82358733}, {0x4DB1, 0x82358734}, {0x4DB2, 0x82358735}, {0x4DB3, 0x82358736}, {0x4DB4, 0x82358737}, {0x4DB5, 0x82358738}, {0x4DB6, 0x82358739}, {0x4DB7, 0x82358830}, {0x4DB8, 0x82358831}, {0x4DB9, 0x82358832}, {0x4DBA, 0x82358833}, {0x4DBB, 0x82358834}, {0x4DBC, 0x82358835}, {0x4DBD, 0x82358836}, {0x4DBE, 0x82358837}, {0x4DBF, 0x82358838}, {0x4DC0, 0x82358839}, {0x4DC1, 0x82358930}, {0x4DC2, 0x82358931}, {0x4DC3, 0x82358932}, {0x4DC4, 0x82358933}, {0x4DC5, 0x82358934}, {0x4DC6, 0x82358935}, {0x4DC7, 0x82358936}, {0x4DC8, 0x82358937}, {0x4DC9, 0x82358938}, {0x4DCA, 0x82358939}, {0x4DCB, 0x82358A30}, {0x4DCC, 0x82358A31}, {0x4DCD, 0x82358A32}, {0x4DCE, 0x82358A33}, {0x4DCF, 0x82358A34}, {0x4DD0, 0x82358A35}, {0x4DD1, 0x82358A36}, {0x4DD2, 0x82358A37}, {0x4DD3, 0x82358A38}, {0x4DD4, 0x82358A39}, {0x4DD5, 0x82358B30}, {0x4DD6, 0x82358B31}, {0x4DD7, 0x82358B32}, {0x4DD8, 0x82358B33}, {0x4DD9, 0x82358B34}, {0x4DDA, 0x82358B35}, {0x4DDB, 0x82358B36}, {0x4DDC, 0x82358B37}, {0x4DDD, 0x82358B38}, {0x4DDE, 0x82358B39}, {0x4DDF, 0x82358C30}, {0x4DE0, 0x82358C31}, {0x4DE1, 0x82358C32}, {0x4DE2, 0x82358C33}, {0x4DE3, 0x82358C34}, {0x4DE4, 0x82358C35}, {0x4DE5, 0x82358C36}, {0x4DE6, 0x82358C37}, {0x4DE7, 0x82358C38}, {0x4DE8, 0x82358C39}, {0x4DE9, 0x82358D30}, {0x4DEA, 0x82358D31}, {0x4DEB, 0x82358D32}, {0x4DEC, 0x82358D33}, {0x4DED, 0x82358D34}, {0x4DEE, 0x82358D35}, {0x4DEF, 0x82358D36}, {0x4DF0, 0x82358D37}, {0x4DF1, 0x82358D38}, {0x4DF2, 0x82358D39}, {0x4DF3, 0x82358E30}, {0x4DF4, 0x82358E31}, {0x4DF5, 0x82358E32}, {0x4DF6, 0x82358E33}, {0x4DF7, 0x82358E34}, {0x4DF8, 0x82358E35}, {0x4DF9, 0x82358E36}, {0x4DFA, 0x82358E37}, {0x4DFB, 0x82358E38}, {0x4DFC, 0x82358E39}, {0x4DFD, 0x82358F30}, {0x4DFE, 0x82358F31}, {0x4DFF, 0x82358F32}, {0xE76C, 0x8336C739}, {0xE7C7, 0x8135F437}, {0xE7C8, 0x8336C830}, {0xE7E7, 0x8336C831}, {0xE7E8, 0x8336C832}, {0xE7E9, 0x8336C833}, {0xE7EA, 0x8336C834}, {0xE7EB, 0x8336C835}, {0xE7EC, 0x8336C836}, {0xE7ED, 0x8336C837}, {0xE7EE, 0x8336C838}, {0xE7EF, 0x8336C839}, {0xE7F0, 0x8336C930}, {0xE7F1, 0x8336C931}, {0xE7F2, 0x8336C932}, {0xE7F3, 0x8336C933}, {0xE815, 0x8336C934}, {0xE819, 0x8336C935}, {0xE81A, 0x8336C936}, {0xE81B, 0x8336C937}, {0xE81C, 0x8336C938}, {0xE81D, 0x8336C939}, {0xE81F, 0x8336CA30}, {0xE820, 0x8336CA31}, {0xE821, 0x8336CA32}, {0xE822, 0x8336CA33}, {0xE823, 0x8336CA34}, {0xE824, 0x8336CA35}, {0xE825, 0x8336CA36}, {0xE827, 0x8336CA37}, {0xE828, 0x8336CA38}, {0xE829, 0x8336CA39}, {0xE82A, 0x8336CB30}, {0xE82D, 0x8336CB31}, {0xE82E, 0x8336CB32}, {0xE82F, 0x8336CB33}, {0xE830, 0x8336CB34}, {0xE833, 0x8336CB35}, {0xE834, 0x8336CB36}, {0xE835, 0x8336CB37}, {0xE836, 0x8336CB38}, {0xE837, 0x8336CB39}, {0xE838, 0x8336CC30}, {0xE839, 0x8336CC31}, {0xE83A, 0x8336CC32}, {0xE83C, 0x8336CC33}, {0xE83D, 0x8336CC34}, {0xE83E, 0x8336CC35}, {0xE83F, 0x8336CC36}, {0xE840, 0x8336CC37}, {0xE841, 0x8336CC38}, {0xE842, 0x8336CC39}, {0xE844, 0x8336CD30}, {0xE845, 0x8336CD31}, {0xE846, 0x8336CD32}, {0xE847, 0x8336CD33}, {0xE848, 0x8336CD34}, {0xE849, 0x8336CD35}, {0xE84A, 0x8336CD36}, {0xE84B, 0x8336CD37}, {0xE84C, 0x8336CD38}, {0xE84D, 0x8336CD39}, {0xE84E, 0x8336CE30}, {0xE84F, 0x8336CE31}, {0xE850, 0x8336CE32}, {0xE851, 0x8336CE33}, {0xE852, 0x8336CE34}, {0xE853, 0x8336CE35}, {0xE856, 0x8336CE36}, {0xE857, 0x8336CE37}, {0xE858, 0x8336CE38}, {0xE859, 0x8336CE39}, {0xE85A, 0x8336CF30}, {0xE85B, 0x8336CF31}, {0xE85C, 0x8336CF32}, {0xE85D, 0x8336CF33}, {0xE85E, 0x8336CF34}, {0xE85F, 0x8336CF35}, {0xE860, 0x8336CF36}, {0xE861, 0x8336CF37}, {0xE862, 0x8336CF38}, {0xE863, 0x8336CF39}, {0xF92D, 0x84308535}, {0xF92E, 0x84308536}, {0xF92F, 0x84308537}, {0xF930, 0x84308538}, {0xF931, 0x84308539}, {0xF932, 0x84308630}, {0xF933, 0x84308631}, {0xF934, 0x84308632}, {0xF935, 0x84308633}, {0xF936, 0x84308634}, {0xF937, 0x84308635}, {0xF938, 0x84308636}, {0xF939, 0x84308637}, {0xF93A, 0x84308638}, {0xF93B, 0x84308639}, {0xF93C, 0x84308730}, {0xF93D, 0x84308731}, {0xF93E, 0x84308732}, {0xF93F, 0x84308733}, {0xF940, 0x84308734}, {0xF941, 0x84308735}, {0xF942, 0x84308736}, {0xF943, 0x84308737}, {0xF944, 0x84308738}, {0xF945, 0x84308739}, {0xF946, 0x84308830}, {0xF947, 0x84308831}, {0xF948, 0x84308832}, {0xF949, 0x84308833}, {0xF94A, 0x84308834}, {0xF94B, 0x84308835}, {0xF94C, 0x84308836}, {0xF94D, 0x84308837}, {0xF94E, 0x84308838}, {0xF94F, 0x84308839}, {0xF950, 0x84308930}, {0xF951, 0x84308931}, {0xF952, 0x84308932}, {0xF953, 0x84308933}, {0xF954, 0x84308934}, {0xF955, 0x84308935}, {0xF956, 0x84308936}, {0xF957, 0x84308937}, {0xF958, 0x84308938}, {0xF959, 0x84308939}, {0xF95A, 0x84308A30}, {0xF95B, 0x84308A31}, {0xF95C, 0x84308A32}, {0xF95D, 0x84308A33}, {0xF95E, 0x84308A34}, {0xF95F, 0x84308A35}, {0xF960, 0x84308A36}, {0xF961, 0x84308A37}, {0xF962, 0x84308A38}, {0xF963, 0x84308A39}, {0xF964, 0x84308B30}, {0xF965, 0x84308B31}, {0xF966, 0x84308B32}, {0xF967, 0x84308B33}, {0xF968, 0x84308B34}, {0xF969, 0x84308B35}, {0xF96A, 0x84308B36}, {0xF96B, 0x84308B37}, {0xF96C, 0x84308B38}, {0xF96D, 0x84308B39}, {0xF96E, 0x84308C30}, {0xF96F, 0x84308C31}, {0xF970, 0x84308C32}, {0xF971, 0x84308C33}, {0xF972, 0x84308C34}, {0xF973, 0x84308C35}, {0xF974, 0x84308C36}, {0xF975, 0x84308C37}, {0xF976, 0x84308C38}, {0xF977, 0x84308C39}, {0xF978, 0x84308D30}, {0xF97A, 0x84308D31}, {0xF97B, 0x84308D32}, {0xF97C, 0x84308D33}, {0xF97D, 0x84308D34}, {0xF97E, 0x84308D35}, {0xF97F, 0x84308D36}, {0xF980, 0x84308D37}, {0xF981, 0x84308D38}, {0xF982, 0x84308D39}, {0xF983, 0x84308E30}, {0xF984, 0x84308E31}, {0xF985, 0x84308E32}, {0xF986, 0x84308E33}, {0xF987, 0x84308E34}, {0xF988, 0x84308E35}, {0xF989, 0x84308E36}, {0xF98A, 0x84308E37}, {0xF98B, 0x84308E38}, {0xF98C, 0x84308E39}, {0xF98D, 0x84308F30}, {0xF98E, 0x84308F31}, {0xF98F, 0x84308F32}, {0xF990, 0x84308F33}, {0xF991, 0x84308F34}, {0xF992, 0x84308F35}, {0xF993, 0x84308F36}, {0xF994, 0x84308F37}, {0xF996, 0x84308F38}, {0xF997, 0x84308F39}, {0xF998, 0x84309030}, {0xF999, 0x84309031}, {0xF99A, 0x84309032}, {0xF99B, 0x84309033}, {0xF99C, 0x84309034}, {0xF99D, 0x84309035}, {0xF99E, 0x84309036}, {0xF99F, 0x84309037}, {0xF9A0, 0x84309038}, {0xF9A1, 0x84309039}, {0xF9A2, 0x84309130}, {0xF9A3, 0x84309131}, {0xF9A4, 0x84309132}, {0xF9A5, 0x84309133}, {0xF9A6, 0x84309134}, {0xF9A7, 0x84309135}, {0xF9A8, 0x84309136}, {0xF9A9, 0x84309137}, {0xF9AA, 0x84309138}, {0xF9AB, 0x84309139}, {0xF9AC, 0x84309230}, {0xF9AD, 0x84309231}, {0xF9AE, 0x84309232}, {0xF9AF, 0x84309233}, {0xF9B0, 0x84309234}, {0xF9B1, 0x84309235}, {0xF9B2, 0x84309236}, {0xF9B3, 0x84309237}, {0xF9B4, 0x84309238}, {0xF9B5, 0x84309239}, {0xF9B6, 0x84309330}, {0xF9B7, 0x84309331}, {0xF9B8, 0x84309332}, {0xF9B9, 0x84309333}, {0xF9BA, 0x84309334}, {0xF9BB, 0x84309335}, {0xF9BC, 0x84309336}, {0xF9BD, 0x84309337}, {0xF9BE, 0x84309338}, {0xF9BF, 0x84309339}, {0xF9C0, 0x84309430}, {0xF9C1, 0x84309431}, {0xF9C2, 0x84309432}, {0xF9C3, 0x84309433}, {0xF9C4, 0x84309434}, {0xF9C5, 0x84309435}, {0xF9C6, 0x84309436}, {0xF9C7, 0x84309437}, {0xF9C8, 0x84309438}, {0xF9C9, 0x84309439}, {0xF9CA, 0x84309530}, {0xF9CB, 0x84309531}, {0xF9CC, 0x84309532}, {0xF9CD, 0x84309533}, {0xF9CE, 0x84309534}, {0xF9CF, 0x84309535}, {0xF9D0, 0x84309536}, {0xF9D1, 0x84309537}, {0xF9D2, 0x84309538}, {0xF9D3, 0x84309539}, {0xF9D4, 0x84309630}, {0xF9D5, 0x84309631}, {0xF9D6, 0x84309632}, {0xF9D7, 0x84309633}, {0xF9D8, 0x84309634}, {0xF9D9, 0x84309635}, {0xF9DA, 0x84309636}, {0xF9DB, 0x84309637}, {0xF9DC, 0x84309638}, {0xF9DD, 0x84309639}, {0xF9DE, 0x84309730}, {0xF9DF, 0x84309731}, {0xF9E0, 0x84309732}, {0xF9E1, 0x84309733}, {0xF9E2, 0x84309734}, {0xF9E3, 0x84309735}, {0xF9E4, 0x84309736}, {0xF9E5, 0x84309737}, {0xF9E6, 0x84309738}, {0xF9E8, 0x84309739}, {0xF9E9, 0x84309830}, {0xF9EA, 0x84309831}, {0xF9EB, 0x84309832}, {0xF9EC, 0x84309833}, {0xF9ED, 0x84309834}, {0xF9EE, 0x84309835}, {0xF9EF, 0x84309836}, {0xF9F0, 0x84309837}, {0xF9F2, 0x84309838}, {0xF9F3, 0x84309839}, {0xF9F4, 0x84309930}, {0xF9F5, 0x84309931}, {0xF9F6, 0x84309932}, {0xF9F7, 0x84309933}, {0xF9F8, 0x84309934}, {0xF9F9, 0x84309935}, {0xF9FA, 0x84309936}, {0xF9FB, 0x84309937}, {0xF9FC, 0x84309938}, {0xF9FD, 0x84309939}, {0xF9FE, 0x84309A30}, {0xF9FF, 0x84309A31}, {0xFA00, 0x84309A32}, {0xFA01, 0x84309A33}, {0xFA02, 0x84309A34}, {0xFA03, 0x84309A35}, {0xFA04, 0x84309A36}, {0xFA05, 0x84309A37}, {0xFA06, 0x84309A38}, {0xFA07, 0x84309A39}, {0xFA08, 0x84309B30}, {0xFA09, 0x84309B31}, {0xFA0A, 0x84309B32}, {0xFA0B, 0x84309B33}, {0xFA10, 0x84309B34}, {0xFA12, 0x84309B35}, {0xFA15, 0x84309B36}, {0xFA16, 0x84309B37}, {0xFA17, 0x84309B38}, {0xFA19, 0x84309B39}, {0xFA1A, 0x84309C30}, {0xFA1B, 0x84309C31}, {0xFA1C, 0x84309C32}, {0xFA1D, 0x84309C33}, {0xFA1E, 0x84309C34}, {0xFA22, 0x84309C35}, {0xFA25, 0x84309C36}, {0xFA26, 0x84309C37}, {0xFE32, 0x84318538}, {0xFE45, 0x84318539}, {0xFE46, 0x84318630}, {0xFE47, 0x84318631}, {0xFE48, 0x84318632}, {0xFE53, 0x84318633}, {0xFE58, 0x84318634}, {0xFE67, 0x84318635}, {0xFE6C, 0x84318636}, {0xFE6D, 0x84318637}, {0xFE6E, 0x84318638}, {0xFE6F, 0x84318639}, {0xFE70, 0x84318730}, {0xFE71, 0x84318731}, {0xFE72, 0x84318732}, {0xFE73, 0x84318733}, {0xFE74, 0x84318734}, {0xFE75, 0x84318735}, {0xFE76, 0x84318736}, {0xFE77, 0x84318737}, {0xFE78, 0x84318738}, {0xFE79, 0x84318739}, {0xFE7A, 0x84318830}, {0xFE7B, 0x84318831}, {0xFE7C, 0x84318832}, {0xFE7D, 0x84318833}, {0xFE7E, 0x84318834}, {0xFE7F, 0x84318835}, {0xFE80, 0x84318836}, {0xFE81, 0x84318837}, {0xFE82, 0x84318838}, {0xFE83, 0x84318839}, {0xFE84, 0x84318930}, {0xFE85, 0x84318931}, {0xFE86, 0x84318932}, {0xFE87, 0x84318933}, {0xFE88, 0x84318934}, {0xFE89, 0x84318935}, {0xFE8A, 0x84318936}, {0xFE8B, 0x84318937}, {0xFE8C, 0x84318938}, {0xFE8D, 0x84318939}, {0xFE8E, 0x84318A30}, {0xFE8F, 0x84318A31}, {0xFE90, 0x84318A32}, {0xFE91, 0x84318A33}, {0xFE92, 0x84318A34}, {0xFE93, 0x84318A35}, {0xFE94, 0x84318A36}, {0xFE95, 0x84318A37}, {0xFE96, 0x84318A38}, {0xFE97, 0x84318A39}, {0xFE98, 0x84318B30}, {0xFE99, 0x84318B31}, {0xFE9A, 0x84318B32}, {0xFE9B, 0x84318B33}, {0xFE9C, 0x84318B34}, {0xFE9D, 0x84318B35}, {0xFE9E, 0x84318B36}, {0xFE9F, 0x84318B37}, {0xFEA0, 0x84318B38}, {0xFEA1, 0x84318B39}, {0xFEA2, 0x84318C30}, {0xFEA3, 0x84318C31}, {0xFEA4, 0x84318C32}, {0xFEA5, 0x84318C33}, {0xFEA6, 0x84318C34}, {0xFEA7, 0x84318C35}, {0xFEA8, 0x84318C36}, {0xFEA9, 0x84318C37}, {0xFEAA, 0x84318C38}, {0xFEAB, 0x84318C39}, {0xFEAC, 0x84318D30}, {0xFEAD, 0x84318D31}, {0xFEAE, 0x84318D32}, {0xFEAF, 0x84318D33}, {0xFEB0, 0x84318D34}, {0xFEB1, 0x84318D35}, {0xFEB2, 0x84318D36}, {0xFEB3, 0x84318D37}, {0xFEB4, 0x84318D38}, {0xFEB5, 0x84318D39}, {0xFEB6, 0x84318E30}, {0xFEB7, 0x84318E31}, {0xFEB8, 0x84318E32}, {0xFEB9, 0x84318E33}, {0xFEBA, 0x84318E34}, {0xFEBB, 0x84318E35}, {0xFEBC, 0x84318E36}, {0xFEBD, 0x84318E37}, {0xFEBE, 0x84318E38}, {0xFEBF, 0x84318E39}, {0xFEC0, 0x84318F30}, {0xFEC1, 0x84318F31}, {0xFEC2, 0x84318F32}, {0xFEC3, 0x84318F33}, {0xFEC4, 0x84318F34}, {0xFEC5, 0x84318F35}, {0xFEC6, 0x84318F36}, {0xFEC7, 0x84318F37}, {0xFEC8, 0x84318F38}, {0xFEC9, 0x84318F39}, {0xFECA, 0x84319030}, {0xFECB, 0x84319031}, {0xFECC, 0x84319032}, {0xFECD, 0x84319033}, {0xFECE, 0x84319034}, {0xFECF, 0x84319035}, {0xFED0, 0x84319036}, {0xFED1, 0x84319037}, {0xFED2, 0x84319038}, {0xFED3, 0x84319039}, {0xFED4, 0x84319130}, {0xFED5, 0x84319131}, {0xFED6, 0x84319132}, {0xFED7, 0x84319133}, {0xFED8, 0x84319134}, {0xFED9, 0x84319135}, {0xFEDA, 0x84319136}, {0xFEDB, 0x84319137}, {0xFEDC, 0x84319138}, {0xFEDD, 0x84319139}, {0xFEDE, 0x84319230}, {0xFEDF, 0x84319231}, {0xFEE0, 0x84319232}, {0xFEE1, 0x84319233}, {0xFEE2, 0x84319234}, {0xFEE3, 0x84319235}, {0xFEE4, 0x84319236}, {0xFEE5, 0x84319237}, {0xFEE6, 0x84319238}, {0xFEE7, 0x84319239}, {0xFEE8, 0x84319330}, {0xFEE9, 0x84319331}, {0xFEEA, 0x84319332}, {0xFEEB, 0x84319333}, {0xFEEC, 0x84319334}, {0xFEED, 0x84319335}, {0xFEEE, 0x84319336}, {0xFEEF, 0x84319337}, {0xFEF0, 0x84319338}, {0xFEF1, 0x84319339}, {0xFEF2, 0x84319430}, {0xFEF3, 0x84319431}, {0xFEF4, 0x84319432}, {0xFEF5, 0x84319433}, {0xFEF6, 0x84319434}, {0xFEF7, 0x84319435}, {0xFEF8, 0x84319436}, {0xFEF9, 0x84319437}, {0xFEFA, 0x84319438}, {0xFEFB, 0x84319439}, {0xFEFC, 0x84319530}, {0xFEFD, 0x84319531}, {0xFEFE, 0x84319532}, {0xFEFF, 0x84319533}, {0xFF00, 0x84319534}, {0xFF5F, 0x84319535}, {0xFF60, 0x84319536}, {0xFF61, 0x84319537}, {0xFF62, 0x84319538}, {0xFF63, 0x84319539}, {0xFF64, 0x84319630}, {0xFF65, 0x84319631}, {0xFF66, 0x84319632}, {0xFF67, 0x84319633}, {0xFF68, 0x84319634}, {0xFF69, 0x84319635}, {0xFF6A, 0x84319636}, {0xFF6B, 0x84319637}, {0xFF6C, 0x84319638}, {0xFF6D, 0x84319639}, {0xFF6E, 0x84319730}, {0xFF6F, 0x84319731}, {0xFF70, 0x84319732}, {0xFF71, 0x84319733}, {0xFF72, 0x84319734}, {0xFF73, 0x84319735}, {0xFF74, 0x84319736}, {0xFF75, 0x84319737}, {0xFF76, 0x84319738}, {0xFF77, 0x84319739}, {0xFF78, 0x84319830}, {0xFF79, 0x84319831}, {0xFF7A, 0x84319832}, {0xFF7B, 0x84319833}, {0xFF7C, 0x84319834}, {0xFF7D, 0x84319835}, {0xFF7E, 0x84319836}, {0xFF7F, 0x84319837}, {0xFF80, 0x84319838}, {0xFF81, 0x84319839}, {0xFF82, 0x84319930}, {0xFF83, 0x84319931}, {0xFF84, 0x84319932}, {0xFF85, 0x84319933}, {0xFF86, 0x84319934}, {0xFF87, 0x84319935}, {0xFF88, 0x84319936}, {0xFF89, 0x84319937}, {0xFF8A, 0x84319938}, {0xFF8B, 0x84319939}, {0xFF8C, 0x84319A30}, {0xFF8D, 0x84319A31}, {0xFF8E, 0x84319A32}, {0xFF8F, 0x84319A33}, {0xFF90, 0x84319A34}, {0xFF91, 0x84319A35}, {0xFF92, 0x84319A36}, {0xFF93, 0x84319A37}, {0xFF94, 0x84319A38}, {0xFF95, 0x84319A39}, {0xFF96, 0x84319B30}, {0xFF97, 0x84319B31}, {0xFF98, 0x84319B32}, {0xFF99, 0x84319B33}, {0xFF9A, 0x84319B34}, {0xFF9B, 0x84319B35}, {0xFF9C, 0x84319B36}, {0xFF9D, 0x84319B37}, {0xFF9E, 0x84319B38}, {0xFF9F, 0x84319B39}, {0xFFA0, 0x84319C30}, {0xFFA1, 0x84319C31}, {0xFFA2, 0x84319C32}, {0xFFA3, 0x84319C33}, {0xFFA4, 0x84319C34}, {0xFFA5, 0x84319C35}, {0xFFA6, 0x84319C36}, {0xFFA7, 0x84319C37}, {0xFFA8, 0x84319C38}, {0xFFA9, 0x84319C39}, {0xFFAA, 0x84319D30}, {0xFFAB, 0x84319D31}, {0xFFAC, 0x84319D32}, {0xFFAD, 0x84319D33}, {0xFFAE, 0x84319D34}, {0xFFAF, 0x84319D35}, {0xFFB0, 0x84319D36}, {0xFFB1, 0x84319D37}, {0xFFB2, 0x84319D38}, {0xFFB3, 0x84319D39}, {0xFFB4, 0x84319E30}, {0xFFB5, 0x84319E31}, {0xFFB6, 0x84319E32}, {0xFFB7, 0x84319E33}, {0xFFB8, 0x84319E34}, {0xFFB9, 0x84319E35}, {0xFFBA, 0x84319E36}, {0xFFBB, 0x84319E37}, {0xFFBC, 0x84319E38}, {0xFFBD, 0x84319E39}, {0xFFBE, 0x84319F30}, {0xFFBF, 0x84319F31}, {0xFFC0, 0x84319F32}, {0xFFC1, 0x84319F33}, {0xFFC2, 0x84319F34}, {0xFFC3, 0x84319F35}, {0xFFC4, 0x84319F36}, {0xFFC5, 0x84319F37}, {0xFFC6, 0x84319F38}, {0xFFC7, 0x84319F39}, {0xFFC8, 0x8431A030}, {0xFFC9, 0x8431A031}, {0xFFCA, 0x8431A032}, {0xFFCB, 0x8431A033}, {0xFFCC, 0x8431A034}, {0xFFCD, 0x8431A035}, {0xFFCE, 0x8431A036}, {0xFFCF, 0x8431A037}, {0xFFD0, 0x8431A038}, {0xFFD1, 0x8431A039}, {0xFFD2, 0x8431A130}, {0xFFD3, 0x8431A131}, {0xFFD4, 0x8431A132}, {0xFFD5, 0x8431A133}, {0xFFD6, 0x8431A134}, {0xFFD7, 0x8431A135}, {0xFFD8, 0x8431A136}, {0xFFD9, 0x8431A137}, {0xFFDA, 0x8431A138}, {0xFFDB, 0x8431A139}, {0xFFDC, 0x8431A230}, {0xFFDD, 0x8431A231}, {0xFFDE, 0x8431A232}, {0xFFDF, 0x8431A233}, }
gb18030-data.go
0.658308
0.428652
gb18030-data.go
starcoder
package p295 /** Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. Examples: [2,3,4] , the median is 3 [2,3], the median is (2 + 3) / 2 = 2.5 Design a data structure that supports the following two operations: void addNum(int num) - Add a integer number from the data stream to the data structure. double findMedian() - Return the median of all elements so far. For example: addNum(1) addNum(2) findMedian() -> 1.5 addNum(3) findMedian() -> 2 */ // a max heap and a min heap type MaxPq struct { pq []int } func (p *MaxPq) swim(k int) { for k > 0 && p.pq[(k-1)>>1] < p.pq[k] { p.pq[(k-1)>>1], p.pq[k] = p.pq[k], p.pq[(k-1)>>1] k = (k - 1) >> 1 } } func (p *MaxPq) sink(k int) { n := len(p.pq) for (k<<1)+1 < n { j := (k << 1) + 1 if j < n-1 && p.pq[j] < p.pq[j+1] { j++ } if p.pq[j] > p.pq[k] { p.pq[j], p.pq[k] = p.pq[k], p.pq[j] } else { break } k = j } } func (p *MaxPq) Insert(v int) { n := len(p.pq) p.pq = append(p.pq, v) p.swim(n) } func (p *MaxPq) Max() int { return p.pq[0] } func (p *MaxPq) DelMax() { n := len(p.pq) p.pq[0], p.pq[n-1] = p.pq[n-1], p.pq[0] p.pq = p.pq[:n-1] p.sink(0) } func (p *MaxPq) Empty() bool { return len(p.pq) == 0 } type MedianFinder struct { maxHeap MaxPq minHeap MaxPq } /** initialize your data structure here. */ func Constructor() MedianFinder { return MedianFinder{ maxHeap: MaxPq{make([]int, 0)}, minHeap: MaxPq{make([]int, 0)}, } } func (this *MedianFinder) AddNum(num int) { this.maxHeap.Insert(num) max := this.maxHeap.Max() this.minHeap.Insert(-max) this.maxHeap.DelMax() if len(this.maxHeap.pq) < len(this.minHeap.pq) { min := -this.minHeap.Max() this.maxHeap.Insert(min) this.minHeap.DelMax() } } func (this *MedianFinder) FindMedian() float64 { res := 0.0 if len(this.maxHeap.pq) == len(this.minHeap.pq) { res = float64(this.maxHeap.Max()-this.minHeap.Max()) / 2.0 } else if len(this.maxHeap.pq) < len(this.minHeap.pq) { res = float64(-this.minHeap.Max()) } else { res = float64(this.maxHeap.Max()) } return res } /** * Your MedianFinder object will be instantiated and called as such: * obj := Constructor(); * obj.AddNum(num); * param_2 := obj.FindMedian(); */
algorithms/p295/295.go
0.810441
0.787992
295.go
starcoder
package tetra3d import ( "math" "sort" "time" "github.com/hajimehoshi/ebiten/v2" "github.com/kvartborg/vector" ) // Model represents a singular visual instantiation of a Mesh. A Mesh contains the vertex information (what to draw); a Model references the Mesh to draw it with a specific // Position, Rotation, and/or Scale (where and how to draw). type Model struct { *Node Mesh *Mesh FrustumCulling bool // Whether the Model is culled when it leaves the frustum. Color *Color // The overall color of the Model. ColorBlendingFunc func(model *Model) ebiten.ColorM BoundingSphere *BoundingSphere BoundingAABB *BoundingAABB Skinned bool // If the model is skinned and this is enabled, the model will tranform its vertices to match its target armature skinMatrix Matrix4 bones [][]*Node vectorPool *VectorPool } var defaultColorBlendingFunc = func(model *Model) ebiten.ColorM { colorM := ebiten.ColorM{} colorM.Scale(model.Color.RGBA64()) return colorM } // NewModel creates a new Model (or instance) of the Mesh and Name provided. A Model represents a singular visual instantiation of a Mesh. func NewModel(mesh *Mesh, name string) *Model { model := &Model{ Node: NewNode(name), Mesh: mesh, FrustumCulling: true, Color: NewColor(1, 1, 1, 1), ColorBlendingFunc: defaultColorBlendingFunc, skinMatrix: NewMatrix4(), } if mesh != nil { model.vectorPool = NewVectorPool(len(mesh.Vertices)) } model.onTransformUpdate = func() { model.BoundingSphere.SetLocalPosition(model.WorldPosition().Add(model.Mesh.Dimensions.Center())) model.BoundingSphere.Radius = model.Mesh.Dimensions.Max() / 2 } radius := 0.0 if mesh != nil { radius = mesh.Dimensions.Max() / 2 } model.BoundingSphere = NewBoundingSphere("bounding sphere", radius) return model } // Clone creates a clone of the Model. func (model *Model) Clone() INode { newModel := NewModel(model.Mesh, model.name) newModel.BoundingSphere = model.BoundingSphere.Clone().(*BoundingSphere) newModel.FrustumCulling = model.FrustumCulling newModel.visible = model.visible newModel.Color = model.Color.Clone() newModel.Skinned = model.Skinned for i := range model.bones { newModel.bones = append(newModel.bones, append([]*Node{}, model.bones[i]...)) } newModel.Node = model.Node.Clone().(*Node) for _, child := range newModel.children { child.setParent(newModel) } return newModel } // Merge merges the provided models into the calling Model. You can use this to merge several objects initially dynamically placed into the calling Model's mesh, // thereby saving on draw calls. Note that the finished Mesh still only uses one Image for texturing, so this is best done between objects that share textures or // tilemaps. func (model *Model) Merge(models ...*Model) { for _, other := range models { p, s, r := model.Transform().Decompose() op, os, or := other.Transform().Decompose() inverted := NewMatrix4Scale(os[0], os[1], os[2]) scaleMatrix := NewMatrix4Scale(s[0], s[1], s[2]) inverted = inverted.Mult(scaleMatrix) inverted = inverted.Mult(r.Transposed().Mult(or)) inverted = inverted.Mult(NewMatrix4Translate(op[0]-p[0], op[1]-p[1], op[2]-p[2])) verts := []*Vertex{} for i := 0; i < len(other.Mesh.Vertices); i += 3 { v0 := other.Mesh.Vertices[i].Clone() v0.Position = inverted.MultVec(v0.Position) v1 := other.Mesh.Vertices[i+1].Clone() v1.Position = inverted.MultVec(v1.Position) v2 := other.Mesh.Vertices[i+2].Clone() v2.Position = inverted.MultVec(v2.Position) verts = append(verts, v0, v1, v2) } model.Mesh.AddTriangles(verts...) } model.Mesh.UpdateBounds() model.BoundingSphere.SetLocalPosition(model.Mesh.Dimensions.Center()) model.BoundingSphere.Radius = model.Mesh.Dimensions.Max() / 2 model.vectorPool = NewVectorPool(len(model.Mesh.Vertices)) } // ReassignBones reassigns the model to point to a different armature. armatureNode should be a pointer to the starting object Node of the // armature (not any of its bones). func (model *Model) ReassignBones(armatureNode *Node) { if len(model.bones) == 0 { return } bones := armatureNode.ChildrenRecursive(false) boneMap := map[string]*Node{} for _, b := range bones { boneMap[b.Name()] = b.(*Node) } for vertexIndex := range model.bones { for i := range model.bones[vertexIndex] { newBone := boneMap[model.bones[vertexIndex][i].name] if newBone.inverseBindMatrix.IsZero() { newBone.inverseBindMatrix = model.bones[vertexIndex][i].inverseBindMatrix.Clone() } model.bones[vertexIndex][i] = newBone } } } func (model *Model) skinVertex(vertex *Vertex) vector.Vector { // Avoid reallocating a new matrix for every vertex; that's wasteful model.skinMatrix.Clear() for boneIndex, bone := range model.bones[vertex.ID] { weightPerc := float64(vertex.Weights[boneIndex]) // The correct way to do this according to GLTF is to multiply the bone by the inverse of the model matrix, but // we don't have to because we simply don't multiply the vertex by the model matrix in the first place if it's skinned. influence := fastMatrixMult(bone.inverseBindMatrix, bone.Transform()) if weightPerc == 1 { model.skinMatrix = influence } else { model.skinMatrix = model.skinMatrix.Add(influence.ScaleByScalar(weightPerc)) } } vertOut := model.skinMatrix.MultVecW(vertex.Position) return vertOut } func (model *Model) TransformedVertices(vpMatrix Matrix4, viewPos vector.Vector, camera *Camera) []*Triangle { mvp := model.Transform().Mult(vpMatrix) model.vectorPool.Reset() if model.Skinned { t := time.Now() // If we're skinning a model, it will automatically copy the armature's position, scale, and rotation by copying its bones for _, tri := range model.Mesh.Triangles { tri.closestDepth = math.MaxFloat64 for _, vert := range tri.Vertices { vert.transformed = model.vectorPool.MultVecW(vpMatrix, model.skinVertex(vert)) if vert.transformed[2] < tri.closestDepth { tri.closestDepth = vert.transformed[2] } } } camera.DebugInfo.animationTime += time.Since(t) } else { for _, tri := range model.Mesh.Triangles { tri.closestDepth = math.MaxFloat64 for _, vert := range tri.Vertices { vert.transformed = model.vectorPool.MultVecW(mvp, vert.Position) if vert.transformed[2] < tri.closestDepth { tri.closestDepth = vert.transformed[2] } } } } sortMode := TriangleSortBackToFront if model.Mesh.Material != nil { sortMode = model.Mesh.Material.TriangleSortMode } if sortMode == TriangleSortBackToFront { sort.SliceStable(model.Mesh.sortedTriangles, func(i, j int) bool { return model.Mesh.sortedTriangles[i].closestDepth > model.Mesh.sortedTriangles[j].closestDepth }) } else if sortMode == TriangleSortFrontToBack { sort.SliceStable(model.Mesh.sortedTriangles, func(i, j int) bool { return model.Mesh.sortedTriangles[i].closestDepth < model.Mesh.sortedTriangles[j].closestDepth }) } return model.Mesh.sortedTriangles } // AddChildren parents the provided children Nodes to the passed parent Node, inheriting its transformations and being under it in the scenegraph // hierarchy. If the children are already parented to other Nodes, they are unparented before doing so. func (model *Model) AddChildren(children ...INode) { // We do this manually so that addChildren() parents the children to the Model, rather than to the Model.NodeBase. model.addChildren(model, children...) } // Unparent unparents the Model from its parent, removing it from the scenegraph. func (model *Model) Unparent() { if model.parent != nil { model.parent.RemoveChildren(model) } }
model.go
0.810816
0.682561
model.go
starcoder
package main import ( "fmt" log "github.com/sirupsen/logrus" ) type board struct { Solution []*Square Squares [9]*Square CurrentPosition int8 } // Recursive function that takes the current solution and unused squares // and determines the position/orientation of the next empty position func (b *board) solve() bool { // Our breakout condition (board is solved!) if b.CurrentPosition == 8 { return true } // Looping through each unused square and trying it out for i := 0; i < 9; i++ { if !b.Squares[i].Used { b.addSquare(i) // Here we loop through and flip the squares around if the don't fit for j := 0; j < 4; j++ { if b.isLastSquareValid() { log.Infof("Position %d is valid", b.CurrentPosition) solved := b.solve() if solved { // the rest of the puzzle is solved, we're done here return true } log.Infof("Square %d in position %d cannot be solved", i, b.CurrentPosition) break } else { log.Infof("Position %d is invalid", b.CurrentPosition) } // Dont' really need to rotate on the last loop (save ourselves some time) if j < 3 { b.Squares[i].rotate() } } b.removeSquare() } } return false } // AddSquare adds a square to the next open position on the board and marks it used func (b *board) addSquare(i int) { b.Solution = append(b.Solution, b.Squares[i]) b.CurrentPosition++ b.Squares[i].Used = true log.Infof("Added square %d to position %d", i, b.CurrentPosition) } // RemoveSquare removes a square in the current position on the board and marks it unused func (b *board) removeSquare() { var squareRemoved *Square squareRemoved, b.Solution = b.Solution[b.CurrentPosition], b.Solution[:b.CurrentPosition] log.Infof("Removed square %s in position %d", squareRemoved.Id, b.CurrentPosition) b.CurrentPosition-- squareRemoved.Used = false } // Checks that the last piece placed on the board is valid // |0|1|2| // |3|4|5| // |6|7|8| func (b *board) isLastSquareValid() bool { iterations++ position := len(b.Solution) - 1 switch position { case 0: return true case 1: return isMatch(b.Solution[0].right(), b.Solution[1].left()) case 2: return isMatch(b.Solution[1].right(), b.Solution[2].left()) case 3: return isMatch(b.Solution[0].bottom(), b.Solution[3].top()) case 4: return isMatch(b.Solution[3].right(), b.Solution[4].left()) && isMatch(b.Solution[1].bottom(), b.Solution[4].top()) case 5: return isMatch(b.Solution[4].right(), b.Solution[5].left()) && isMatch(b.Solution[2].bottom(), b.Solution[5].top()) case 6: return isMatch(b.Solution[3].bottom(), b.Solution[6].top()) case 7: return isMatch(b.Solution[6].right(), b.Solution[7].left()) && isMatch(b.Solution[4].bottom(), b.Solution[7].top()) case 8: // If one side matches, they all match, no need to check the final side return isMatch(b.Solution[7].right(), b.Solution[8].left()) default: log.Fatal("Should never get here") } // Should never get here return false } // Print prints the current board position and orientation func (b *board) print() { fmt.Println() fmt.Println("First Piece Orientation") fmt.Println("-------------------------------------------") fmt.Printf("| %-11s | %-11s | %-11s |\n", " ", b.Solution[0].Sides[1].Color+"-"+b.Solution[0].Sides[1].End, " ") fmt.Println("-------------------------------------------") fmt.Printf("| %-11s | %-11s | %-11s |\n", b.Solution[0].Sides[0].Color+"-"+b.Solution[0].Sides[0].End, b.Solution[0].Id, b.Solution[0].Sides[2].Color+"-"+b.Solution[0].Sides[2].End) fmt.Println("-------------------------------------------") fmt.Printf("| %-11s | %-11s | %-11s |\n", " ", b.Solution[0].Sides[3].Color+"-"+b.Solution[0].Sides[3].End, " ") fmt.Println("-------------------------------------------") fmt.Println() fmt.Println("Piece Positions") fmt.Println("-------------") fmt.Printf("| %s | %s | %s |\n", b.Solution[0].Id, b.Solution[1].Id, b.Solution[2].Id) fmt.Println("-------------") fmt.Printf("| %s | %s | %s |\n", b.Solution[3].Id, b.Solution[4].Id, b.Solution[5].Id) fmt.Println("-------------") fmt.Printf("| %s | %s | %s |\n", b.Solution[6].Id, b.Solution[7].Id, b.Solution[8].Id) fmt.Println("-------------") fmt.Println() } // Determines if two sides match (same color, different end) func isMatch(side1 *Side, side2 *Side) bool { return side1.Color == side2.Color && side1.End != side2.End }
board.go
0.626238
0.40539
board.go
starcoder
package main import ( "bytes" "fmt" "go/format" "io/ioutil" "log" "os" "text/template" "time" ) type unitType struct { Name string Receiver string Description string Type string Unit string ShortUnit string } var unitTypes = []unitType{ {"TimeOffset", "time", "is the elapsed time", "int64", "milliseconds", "ms"}, {"Speed", "speed", "is the vehicle speed", "float64", "meters per second", "m/s"}, {"SpeedAccuracy", "accuracy", "is the accuracy of the speed measurement", "int", "millimeters per second", "mm/s"}, {"Coordinate", "coordinate", "is a single point on either the lattitudinal or longitudinal axis", "float64", "degrees", "°"}, {"GPSAccuracy", "accuracy", "is the accuracy of the GPS coordinates", "int", "millimeters", "mm"}, {"Heading", "heading", "is the direction something is headed. In the case of course information the heading is the direction the vehicle is moving. For lap markers, the heading is direction the marker is pointing", "float64", "degrees", "°"}, {"HeadingAccuracy", "accuracy", "is the accuracy of the GPS heading", "float64", "degrees", "°"}, {"Acceleration", "acceleration", "is the acceleration of the vehicle in a given direction", "float64", "standard gravity", "G"}, {"GPSTime", "gpsTime", "is the number of milliseconds since midnight between Saturday and Sunday", "uint32", "milliseconds", "ms"}, {"Voltage", "voltage", "is a measurement sampled from the anlog inputs of the data logger", "int", "millivolts", "mV"}, {"Frequency", "freq", "is a measurement sampled from the frequency inputs of the data logger", "float64", "hertz", "hz"}, {"Altitude", "altitude", "is the height above sea level as measured by GPS", "int", "millimeters", "mm"}, {"AltitudeAccuracy", "accuracy", "is the accuracy of the altitude measurement", "int", "millimeters", "mm"}, } const typeTemplate = ` {{generateComment .Name .Description .Unit}} type {{.Name}} {{.Type}} // Format satisfies interface fmt.Formatter func ({{.Receiver}} {{.Name}}) Format(f fmt.State, c rune) { formatUnit(f, c, "{{.ShortUnit}}", {{.Receiver}}, {{.Type}}({{.Receiver}})) } ` var gopath string var unitPkgPath string func generateComment(name, description, unit string) string { return fmt.Sprintf("// %s %s. %s is measured in %s", name, description, name, unit) } func owner() string { return "<NAME>" } func main() { licenseText, _ := ioutil.ReadFile("internal/license.tmpl") funcs := template.FuncMap{"now": time.Now, "owner": owner, "generateComment": generateComment} license := template.Must(template.New("license").Funcs(funcs).Parse(string(licenseText))) form := template.Must(template.New("format").Funcs(funcs).Parse(typeTemplate)) f, err := os.Create("unit_types.go") if err != nil { log.Fatal(err) } defer f.Close() buf := bytes.NewBuffer(make([]byte, 0)) err = license.Execute(buf, struct{}{}) if err != nil { log.Fatal(err) } fmt.Fprintf(buf, "\npackage main\n") fmt.Fprintf(buf, "import \"fmt\"\n") for _, t := range unitTypes { err = form.Execute(buf, t) if err != nil { log.Fatal(err) } } b, err := format.Source(buf.Bytes()) if err != nil { f.Write(buf.Bytes()) // This is here to debug bad format log.Fatalf("error formatting: %s", err) } f.Write(b) }
internal/autogen_types.go
0.623721
0.489015
autogen_types.go
starcoder
package sod_shock_tube import ( "fmt" "time" "github.com/notargets/gocfd/DG2D" "github.com/notargets/gocfd/model_problems/Euler1D" "github.com/notargets/gocfd/utils" ) type InterpolationTarget struct { ElementNumber int // Global K element address RS [2]float64 // Coordinates within element InterpolationMatrix utils.Matrix // Np x 1, Calculated from [R,S] coordinates } type SODShockTube struct { XLocations []float64 // Locations of values for plotting InterpolationTarget []InterpolationTarget Rho, RhoU, E []float64 // Interpolated values from solution, used for validation Npts int // Npts = # Xlocations, Np = Interior solution polynomial nodes DFR2D *DG2D.DFR2D LineChart *utils.LineChart } func NewSODShockTube(nPts int, dfr *DG2D.DFR2D) (st *SODShockTube) { st = &SODShockTube{ XLocations: make([]float64, nPts), InterpolationTarget: make([]InterpolationTarget, nPts), Npts: nPts, Rho: make([]float64, nPts), RhoU: make([]float64, nPts), E: make([]float64, nPts), DFR2D: dfr, LineChart: utils.NewLineChart(1920, 1080, 0, 1, -.1, 2.6), } xfrac := 1. / float64(nPts-1) // Equal spaced samples across [0->1] for i := range st.XLocations { st.XLocations[i] = float64(i) * xfrac if i == 0 { st.XLocations[i] += 0.00001 } if i == nPts-1 { st.XLocations[i] -= 0.00001 } } st.calculateInterpolation() return } func (st *SODShockTube) calculateInterpolation() { var ( dfr = st.DFR2D getInt = dfr.SolutionElement.JB2D.GetInterpMatrix VY = dfr.VY // Get the centerline Y coordinate ymid = 0.5*(VY.Max()-VY.Min()) + VY.Min() ) /* For each point in XLocations, find the element containing and store the coordinates */ for i, x := range st.XLocations { it := st.InterpolationTarget it[i].ElementNumber, it[i].RS[0], it[i].RS[1] = st.getUVCoords(x, ymid) it[i].InterpolationMatrix = getInt( utils.NewVector(1, []float64{it[i].RS[0]}), utils.NewVector(1, []float64{it[i].RS[1]}), ) } } func (st *SODShockTube) getUVCoords(x, y float64) (ElementID int, r, s float64) { var ( Kmax, _ = st.DFR2D.Tris.EToV.Dims() verts [3]int A, B, C [2]float64 // vertex X,Y coords VX, VY = st.DFR2D.VX.DataP, st.DFR2D.VY.DataP v0, v1, v2 [2]float64 P = [2]float64{x, y} EToV = st.DFR2D.Tris.EToV ) minus := func(a, b [2]float64) (c [2]float64) { c[0] = a[0] - b[0] c[1] = a[1] - b[1] return } dot := func(a, b [2]float64) (f float64) { f = a[0]*b[0] + a[1]*b[1] return } for k := 0; k < Kmax; k++ { tri := EToV.Row(k).DataP verts = [3]int{int(tri[0]), int(tri[1]), int(tri[2])} A = [2]float64{VX[verts[0]], VY[verts[0]]} B = [2]float64{VX[verts[1]], VY[verts[1]]} C = [2]float64{VX[verts[2]], VY[verts[2]]} v0 = minus(C, A) v1 = minus(B, A) v2 = minus(P, A) dot00 := dot(v0, v0) dot01 := dot(v0, v1) dot02 := dot(v0, v2) dot11 := dot(v1, v1) dot12 := dot(v1, v2) invDenom := 1. / (dot00*dot11 - dot01*dot01) r = (dot11*dot02 - dot01*dot12) * invDenom s = (dot00*dot12 - dot01*dot02) * invDenom if r >= 0 && s >= 0 && (r+s) <= 1. { ElementID = k return } } err := fmt.Errorf("unable to find point within elements: [%5.3f,%5.3f]", x, y) panic(err) } func (st *SODShockTube) interpolateFields(Q [4]utils.Matrix) { var ( SolPts = utils.NewMatrix(st.DFR2D.SolutionElement.Np, 1) ) for i, it := range st.InterpolationTarget { k := it.ElementNumber copy(SolPts.DataP, Q[0].Col(k).DataP) fM := it.InterpolationMatrix.Mul(SolPts) st.Rho[i] = fM.DataP[0] copy(SolPts.DataP, Q[1].Col(k).DataP) fM = it.InterpolationMatrix.Mul(SolPts) st.RhoU[i] = fM.DataP[0] copy(SolPts.DataP, Q[3].Col(k).DataP) fM = it.InterpolationMatrix.Mul(SolPts) st.E[i] = fM.DataP[0] } } func (st *SODShockTube) Plot(timeT float64, graphDelay time.Duration, Q [4]utils.Matrix) (iRho float64) { st.interpolateFields(Q) st.LineChart.Plot(0, st.XLocations, st.Rho, -.7, "Rho") st.LineChart.Plot(0, st.XLocations, st.RhoU, 0., "RhoU") st.LineChart.Plot(graphDelay, st.XLocations, st.E, 0.7, "E") iRho = Euler1D.AddAnalyticSod(st.LineChart.Chart, st.LineChart.ColorMap, timeT) time.Sleep(graphDelay) return }
model_problems/Euler2D/sod_shock_tube/shock_tube.go
0.663342
0.492066
shock_tube.go
starcoder
func max(a []int) int { result := -1 for i := 0; i < len(a); i++ { if a[i] > result { result = a[i] } } return result } // ref: https://leetcode.com/problems/cherry-pickup/discuss/165218/Java-O(N3)-DP-solution-w-specific-explanation func cherryPickup(grid [][]int) int { // P(x1, y1, x2, y2) 表示 A 走到 (x1, y1) B 走到 (x2, y2) 时的最大值 // 利用恒等式 x1+y1 = x2+y2,对状态进行压缩,P(x1, y1, x2),隐含 y2 = x1+y1-x2 // 为了方便边界条件的处理,这里假设 grid 范围从 1 到 n,0 行 0 列的 P 值均为 0 // 对于任意状态 P(x1, y1, x2) = // 1) 如果 grid(x1, y1) 或 grid(x2, y2) 为 -1,则当前状态为 -1 // 2) 否则,P = 前一状态的最优解 + 当前状态可获得的额外 cherry 数 // 前一状态的最优解 = // 1) (A right, B right), P(x1, y1-1, x2) // 2) (A right, B down ), P(x1, y1-1, x2-1) // 3) (A down , B right), P(x1-1, y1, x2) // 4) (A down , B down ), P(x1-1, y1, x2-1) // 当前状态可获得的额外 cherry 数:如果 (x1, y1) = (x2, y2) 当前仅能获得 grid(x1, y1) 颗草莓,否则 grid(x1, y1) + grid(x2, y2) n := len(grid) P := make([][][]int, n+1) for i := 0; i <= n; i++ { P[i] = make([][]int, n+1) for j := 0; j <= n; j++ { P[i][j] = make([]int, n+1) } } for x1 := 0; x1 <= n; x1++ { for y1 := 0; y1 <= n; y1++ { for x2 := 0; x2 <= n; x2++ { P[x1][y1][x2] = -1 } } } P[0][1][0] = 0 P[0][1][1] = 0 P[1][0][0] = 0 P[1][0][1] = 0 for x1 := 1; x1 <= n; x1++ { for y1 := 1; y1 <= n; y1++ { for x2 := 1; x2 <= n; x2++ { y2 := x1+y1-x2 if y2 >= 1 && y2 <= n { if grid[x1-1][y1-1] == -1 || grid[x2-1][y2-1] == -1 { P[x1][y1][x2] = -1 } else { lastMax := max([]int{P[x1][y1-1][x2], P[x1][y1-1][x2-1], P[x1-1][y1][x2], P[x1-1][y1][x2-1]}) if lastMax == -1 { P[x1][y1][x2] = -1 } else { extra := grid[x1-1][y1-1] + grid[x2-1][y2-1] if x1 == x2 && y1 == y2 { extra = grid[x1-1][y1-1] } P[x1][y1][x2] = lastMax + extra } } } } } } if P[n][n][n] == -1 { return 0 } else { return P[n][n][n] } }
leetcode/cherry-pickup/solution.go
0.680242
0.472744
solution.go
starcoder
package data import ( "fmt" ) // Maze describes a maze type Maze struct { width, height int cells []*Cell in, out *DoorPosition } // NewMaze prepares maze as a matrix of cells with all walls set func NewMaze(width, height int) *Maze { length := width * height cells := make([]*Cell, length) for i := 0; i < length; i++ { x := i % width y := i / width cells[i] = NewCell(x, y) } return &Maze{width, height, cells, nil, nil} } // Width returns a width of maze func (m *Maze) Width() int { return m.width } // Height returns a height of maze func (m *Maze) Height() int { return m.height } // Entrance returns position of maze entrance or nil func (m *Maze) Entrance() *DoorPosition { return m.in } // Exit returns position of maze exit or nil func (m *Maze) Exit() *DoorPosition { return m.out } // EntranceCell returns a Cell near maze entrance func (m *Maze) EntranceCell() *Cell { return m.doorCell(m.in) } // ExitCell returns a Cell near to maze Exit func (m *Maze) ExitCell() *Cell { return m.doorCell(m.out) } // Cell returs a Cell by its coordinates func (m *Maze) Cell(x, y int) *Cell { c, ok := m.cell(x, y) if !ok { panic("Coords out of range") } return c } // AllCells returns a slice to iterate over all maze cells func (m *Maze) AllCells() []*Cell { return m.cells[:] } // AdjacentCell returns a cell adjacent to given coordinates at given position or nil func (m *Maze) AdjacentCell(x, y int, at Direction) *Cell { ax, ay := at.AdjacentCoords(x, y) cell, _ := m.cell(ax, ay) return cell } // SetEntrance sets maze entrance and removes corresponding outer wall func (m *Maze) SetEntrance(side Direction, offset int) { in := NewDoorPosition(side, offset) if m.out != nil && *m.out == *in { panic("This place is already assigned to Exit") } x, y := m.doorCoords(side, offset) m.RemoveOuterWall(x, y, side) m.in = in } // SetExit sets maze exit and removes corresponding outer wall func (m *Maze) SetExit(side Direction, offset int) { out := NewDoorPosition(side, offset) if m.in != nil && *m.in == *out { panic("This place is already assigned to Entrance") } x, y := m.doorCoords(side, offset) m.RemoveOuterWall(x, y, side) m.out = out } // RemoveWalls - remove walls between adjacent cells func (m *Maze) RemoveWalls(x, y int, side Direction) { current := m.Cell(x, y) adjacent := m.AdjacentCell(x, y, side) if nil == adjacent { panic(fmt.Sprintf("There is no adjacent cell for [%d; %d] at %d", x, y, int(side))) } current.SetWallAt(side, false) adjacent.SetWallAt(side.Opposite(), false) } // RemoveOuterWall - remove outer wall func (m *Maze) RemoveOuterWall(x, y int, side Direction) { current := m.Cell(x, y) if m.AdjacentCell(x, y, side) != nil { panic("Target cell is not edge cell") } current.SetWallAt(side, false) } func (m *Maze) isValidCoords(x, y int) bool { return x >= 0 && y >= 0 && x < m.width && y < m.height } func (m *Maze) cell(x, y int) (cell *Cell, ok bool) { if !m.isValidCoords(x, y) { return nil, false } return m.cells[y*m.width+x], true } func (m *Maze) doorCell(door *DoorPosition) *Cell { if door == nil { return nil } x, y := m.doorCoords(door.Side(), door.Offset()) return m.Cell(x, y) } func (m *Maze) doorCoords(side Direction, offset int) (x, y int) { switch side { case TOP: return offset, 0 case RIGHT: return m.width - 1, offset case BOTTOM: return offset, m.height - 1 case LEFT: return 0, offset } panic("Invalid direction") }
pkg/maze/data/maze.go
0.785391
0.46223
maze.go
starcoder
package models import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // AttackSimulationRoot provides operations to manage the attackSimulation property of the microsoft.graph.security entity. type AttackSimulationRoot struct { Entity // Represents simulation automations created to run on a tenant. simulationAutomations []SimulationAutomationable // Represents an attack simulation training campaign in a tenant. simulations []Simulationable } // NewAttackSimulationRoot instantiates a new attackSimulationRoot and sets the default values. func NewAttackSimulationRoot()(*AttackSimulationRoot) { m := &AttackSimulationRoot{ Entity: *NewEntity(), } return m } // CreateAttackSimulationRootFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value func CreateAttackSimulationRootFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) { return NewAttackSimulationRoot(), nil } // GetFieldDeserializers the deserialization information for the current model func (m *AttackSimulationRoot) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) { res := m.Entity.GetFieldDeserializers() res["simulationAutomations"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { val, err := n.GetCollectionOfObjectValues(CreateSimulationAutomationFromDiscriminatorValue) if err != nil { return err } if val != nil { res := make([]SimulationAutomationable, len(val)) for i, v := range val { res[i] = v.(SimulationAutomationable) } m.SetSimulationAutomations(res) } return nil } res["simulations"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { val, err := n.GetCollectionOfObjectValues(CreateSimulationFromDiscriminatorValue) if err != nil { return err } if val != nil { res := make([]Simulationable, len(val)) for i, v := range val { res[i] = v.(Simulationable) } m.SetSimulations(res) } return nil } return res } // GetSimulationAutomations gets the simulationAutomations property value. Represents simulation automations created to run on a tenant. func (m *AttackSimulationRoot) GetSimulationAutomations()([]SimulationAutomationable) { if m == nil { return nil } else { return m.simulationAutomations } } // GetSimulations gets the simulations property value. Represents an attack simulation training campaign in a tenant. func (m *AttackSimulationRoot) GetSimulations()([]Simulationable) { if m == nil { return nil } else { return m.simulations } } // Serialize serializes information the current object func (m *AttackSimulationRoot) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) { err := m.Entity.Serialize(writer) if err != nil { return err } if m.GetSimulationAutomations() != nil { cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetSimulationAutomations())) for i, v := range m.GetSimulationAutomations() { cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable) } err = writer.WriteCollectionOfObjectValues("simulationAutomations", cast) if err != nil { return err } } if m.GetSimulations() != nil { cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetSimulations())) for i, v := range m.GetSimulations() { cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable) } err = writer.WriteCollectionOfObjectValues("simulations", cast) if err != nil { return err } } return nil } // SetSimulationAutomations sets the simulationAutomations property value. Represents simulation automations created to run on a tenant. func (m *AttackSimulationRoot) SetSimulationAutomations(value []SimulationAutomationable)() { if m != nil { m.simulationAutomations = value } } // SetSimulations sets the simulations property value. Represents an attack simulation training campaign in a tenant. func (m *AttackSimulationRoot) SetSimulations(value []Simulationable)() { if m != nil { m.simulations = value } }
models/attack_simulation_root.go
0.756268
0.569015
attack_simulation_root.go
starcoder
package linode import ( "context" "encoding/json" "fmt" "strconv" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/linode/linodego" ) func dataSourceLinodeDomainRecord() *schema.Resource { return &schema.Resource{ Read: dataSourceLinodeDomainRecordRead, Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeInt, Optional: true, }, "name": { Type: schema.TypeString, Description: "The name of the Record.", Optional: true, }, "domain_id": { Type: schema.TypeInt, Description: "The associated domain's ID.", Required: true, }, "type": { Type: schema.TypeString, Description: "The type of Record this is in the DNS system.", Computed: true, }, "ttl_sec": { Type: schema.TypeInt, Description: "The amount of time in seconds that this Domain's records may be cached by resolvers or other domain servers.", Computed: true, }, "target": { Type: schema.TypeString, Description: "The target for this Record. This field's actual usage depends on the type of record this represents. For A and AAAA records, this is the address the named Domain should resolve to.", Computed: true, }, "priority": { Type: schema.TypeInt, Description: "The priority of the target host. Lower values are preferred.", Computed: true, }, "weight": { Type: schema.TypeInt, Description: "The relative weight of this Record. Higher values are preferred.", Computed: true, }, "port": { Type: schema.TypeInt, Description: "The port this Record points to.", Computed: true, }, "protocol": { Type: schema.TypeString, Description: "The protocol this Record's service communicates with. Only valid for SRV records.", Computed: true, }, "service": { Type: schema.TypeString, Description: "The service this Record identified. Only valid for SRV records.", Computed: true, }, "tag": { Type: schema.TypeString, Description: "The tag portion of a CAA record.", Computed: true, }, }, } } func dataSourceLinodeDomainRecordRead(d *schema.ResourceData, meta interface{}) error { client := meta.(linodego.Client) domainID := d.Get("domain_id").(int) recordName := d.Get("name").(string) recordID := d.Get("id").(int) if recordName == "" && recordID == 0 { return fmt.Errorf("Record name or ID is required") } var record *linodego.DomainRecord if recordID != 0 { rec, err := client.GetDomainRecord(context.Background(), domainID, recordID) if err != nil { return fmt.Errorf("Error fetching domain record: %v", err) } record = rec } else if recordName != "" { filter, _ := json.Marshal(map[string]interface{}{"name": recordName}) records, err := client.ListDomainRecords(context.Background(), domainID, linodego.NewListOptions(0, string(filter))) if err != nil { return fmt.Errorf("Error listing domain records: %v", err) } if len(records) > 0 { record = &records[0] } } if record != nil { d.SetId(strconv.Itoa(recordID)) d.Set("id", record.ID) d.Set("name", record.Name) d.Set("type", record.Type) d.Set("ttl_sec", record.TTLSec) d.Set("target", record.Target) d.Set("priority", record.Priority) d.Set("protocol", record.Protocol) d.Set("weight", record.Weight) d.Set("port", record.Port) d.Set("service", record.Service) d.Set("tag", record.Tag) return nil } d.SetId("") return fmt.Errorf(`Domain record "%s" for domain %d was not found`, recordName, domainID) }
vendor/github.com/terraform-providers/terraform-provider-linode/linode/data_source_linode_domain_record.go
0.552298
0.404625
data_source_linode_domain_record.go
starcoder
package ast import ( "fmt" "reflect" "sort" "strconv" "strings" "github.com/cozees/cook/pkg/cook/token" "github.com/cozees/cook/pkg/runtime/args" ) func indexes(ctx Context, ns ...Node) (rg []int, err error) { for _, n := range ns { si, sk, err := n.Evaluate(ctx) if err != nil { return nil, err } else if sk != reflect.Int64 { return nil, fmt.Errorf("expression %s is an integer value", n) } rg = append(rg, int(si.(int64))) } sort.Ints(rg) return } func stringOf(ctx Context, ns ...Node) (ses []string, err error) { for _, n := range ns { si, sk, err := n.Evaluate(ctx) if err != nil { return nil, err } else if sk != reflect.String { return nil, fmt.Errorf("expression %s is not a valid string", n) } ses = append(ses, si.(string)) } return } func convertToNum(s string) (interface{}, reflect.Kind, error) { if iv, err := strconv.ParseInt(s, 10, 64); err == nil { return iv, reflect.Int64, nil } else if fv, err := strconv.ParseFloat(s, 64); err == nil { return fv, reflect.Float64, nil } else { return nil, reflect.Invalid, err } } func convertToFloat(ctx Context, val interface{}, kind reflect.Kind) (float64, error) { switch kind { case reflect.Int64: return float64(val.(int64)), nil case reflect.Float64: return val.(float64), nil case reflect.String: return strconv.ParseFloat(val.(string), 64) default: return 0, fmt.Errorf("value %v cannot cast/convert to float", val) } } func convertToInt(ctx Context, val interface{}, kind reflect.Kind) (int64, error) { switch kind { case reflect.Int64: return val.(int64), nil case reflect.Float64: return 0, fmt.Errorf("value %v will be cut when cast to integer, use integer(number) instead", val) case reflect.String: return strconv.ParseInt(val.(string), 10, 64) default: return 0, fmt.Errorf("value %v cannot cast to integer", val) } } func convertToString(ctx Context, val interface{}, kind reflect.Kind) (string, error) { switch kind { case reflect.Int64: return strconv.FormatInt(val.(int64), 10), nil case reflect.Float64: return strconv.FormatFloat(val.(float64), 'g', -1, 64), nil case reflect.Bool: return strconv.FormatBool(val.(bool)), nil case reflect.String: return val.(string), nil default: if b, ok := val.([]byte); ok { return string(b), nil } else { return "", fmt.Errorf("value %v cannot cast to string", val) } } } func expandArrayTo(ctx Context, rv reflect.Value, array []string) ([]string, error) { var err error var sv string for i := 0; i < rv.Len(); i++ { v := rv.Index(i) switch v.Kind() { case reflect.Array, reflect.Slice: if array, err = expandArrayTo(ctx, v, array); err != nil { return nil, err } default: i := v.Interface() if sv, err = convertToString(ctx, i, reflect.ValueOf(i).Kind()); err != nil { return nil, err } else { array = append(array, sv) } } } return array, nil } func expandArrayToFuncArgs(ctx Context, rv reflect.Value, array []*args.FunctionArg) []*args.FunctionArg { for i := 0; i < rv.Len(); i++ { v := rv.Index(i) switch v.Kind() { case reflect.Array, reflect.Slice: array = expandArrayToFuncArgs(ctx, v, array) default: i := v.Interface() array = append(array, &args.FunctionArg{Val: i, Kind: reflect.ValueOf(i).Kind()}) } } return array } func addOperator(ctx Context, vl, vr interface{}, vkl, vkr reflect.Kind) (interface{}, reflect.Kind, error) { // array operation // 0: 1 + ["a", 2, 3.5] => [1, "a", 2, 3.5] // 1: ["b", 123, true] + 2.1 => ["b", 123, true, 2.1] // 2: [1, 2] + ["a", true] => [1, 2, "a", true] head := 0 switch { case vkl == reflect.Slice: if vkr == reflect.Slice { head = 2 } else { head = 1 } goto opOnArray case vkr == reflect.Slice: goto opOnArray case vkl == reflect.String || vkr == reflect.String: if s1, err := convertToString(ctx, vl, vkl); err != nil { return nil, 0, err } else if s2, err := convertToString(ctx, vr, vkr); err != nil { return nil, 0, err } else { return s1 + s2, reflect.String, nil } case vkl == reflect.Float64 || vkr == reflect.Float64: if f1, err := convertToFloat(ctx, vl, vkl); err != nil { return nil, 0, err } else if f2, err := convertToFloat(ctx, vr, vkr); err != nil { return nil, 0, err } else { return f1 + f2, reflect.Float64, nil } case vkl == reflect.Int64 && vkr == reflect.Int64: return vl.(int64) + vr.(int64), reflect.Int64, nil } // value is not suitable to operate with + operator return nil, reflect.Invalid, fmt.Errorf("operator + is not supported for value %v and %v", vl, vr) opOnArray: switch head { case 0: return append([]interface{}{vl}, vr.([]interface{})...), reflect.Slice, nil case 1: return append(vl.([]interface{}), vr), reflect.Slice, nil case 2: return append(vl.([]interface{}), vr.([]interface{})...), reflect.Slice, nil default: panic("illegal state for array operation") } } func numOperator(ctx Context, op token.Token, vl, vr interface{}, vkl, vkr reflect.Kind) (interface{}, reflect.Kind, error) { switch { case vkl == reflect.Float64 || vkr == reflect.Float64: if token.ADD < op && op < token.REM { goto numFloat } case vkl == reflect.Int64 || vkr == reflect.Int64: if token.ADD < op && op < token.LAND { goto numInt } } // value is not suitable return nil, reflect.Invalid, fmt.Errorf("operator %s is not supported for value %v and %v", op, vl, vr) numFloat: if fa, err := convertToFloat(ctx, vl, vkl); err != nil { return nil, 0, err } else if fb, err := convertToFloat(ctx, vr, vkr); err != nil { return nil, 0, err } else { switch op { case token.SUB: return fa - fb, reflect.Float64, nil case token.MUL: return fa * fb, reflect.Float64, nil case token.QUO: return fa / fb, reflect.Float64, nil default: panic("illegal state operation") } } numInt: if ia, err := convertToInt(ctx, vl, vkl); err != nil { return nil, 0, err } else if ib, err := convertToInt(ctx, vr, vkr); err != nil { return nil, 0, err } else { switch op { case token.SUB: return ia - ib, reflect.Int64, nil case token.MUL: return ia * ib, reflect.Int64, nil case token.QUO: return ia / ib, reflect.Int64, nil case token.REM: return ia % ib, reflect.Int64, nil case token.AND: return ia & ib, reflect.Int64, nil case token.OR: return ia | ib, reflect.Int64, nil case token.XOR: return ia ^ ib, reflect.Int64, nil case token.SHL: return ia << ib, reflect.Int64, nil case token.SHR: return ia >> ib, reflect.Int64, nil default: panic("illegal state operation") } } } func logicOperator(ctx Context, op token.Token, vl, vr interface{}, vkl, vkr reflect.Kind) (interface{}, reflect.Kind, error) { if (vkl == reflect.Float64 || vkl == reflect.Int64) && (vkr == reflect.Float64 || vkr == reflect.Int64) { if fl, err := convertToFloat(ctx, vl, vkl); err != nil { return nil, 0, err } else if fr, err := convertToFloat(ctx, vr, vkr); err != nil { return nil, 0, err } else { switch op { case token.EQL: return fl == fr, reflect.Bool, nil case token.LSS: return fl < fr, reflect.Bool, nil case token.GTR: return fl > fr, reflect.Bool, nil case token.NEQ: return fl != fr, reflect.Bool, nil case token.LEQ: return fl <= fr, reflect.Bool, nil case token.GEQ: return fl >= fr, reflect.Bool, nil default: panic("illegal state operator") } } } else if vkl == vkr { // any type other than integer or float must has the same type switch vkl { case reflect.Bool: if op == token.EQL { return vl.(bool) == vr.(bool), reflect.Bool, nil } else if op == token.NEQ { return vl.(bool) != vr.(bool), reflect.Bool, nil } case reflect.String: r := strings.Compare(vl.(string), vr.(string)) switch op { case token.EQL: return r == 0, reflect.Bool, nil case token.LSS: return r < 0, reflect.Bool, nil case token.GTR: return r > 0, reflect.Bool, nil case token.NEQ: return r != 0, reflect.Bool, nil case token.LEQ: return r <= 0, reflect.Bool, nil case token.GEQ: return r >= 0, reflect.Bool, nil } default: if op == token.EQL { return vl == vr, reflect.Bool, nil } else if op == token.NEQ { return vl != vr, reflect.Bool, nil } } } // value is not suitable return nil, reflect.Invalid, fmt.Errorf("operator %s is not supported for value %v and %v", op, vl, vr) }
pkg/cook/ast/common.go
0.549641
0.438304
common.go
starcoder
package matchers import ( "fmt" "strings" "github.com/onsi/gomega/types" ) func LookLike(expected string) types.GomegaMatcher { return &lookLikeMatcher{expected: prepare(expected)} } type lookLikeMatcher struct { expected string } var whitespaceReplacer = strings.NewReplacer( " ", "␣", "\t", "⇥", ) func (matcher *lookLikeMatcher) Match(actual interface{}) (success bool, err error) { if given, ok := actual.(string); ok { return matcher.expected == prepare(given), nil } return false, fmt.Errorf("LooksLike matcher expects a string") } func (matcher *lookLikeMatcher) FailureMessage(actual interface{}) (message string) { if given, ok := actual.(string); ok { return fmt.Sprintf("Expected\n%s\nto look like\n%s\n%s", prepare(given), matcher.expected, findDifference(given, matcher.expected)) } return fmt.Sprintf("Expected\n%#v\nto look like\n%s", actual, matcher.expected) } func (matcher *lookLikeMatcher) NegatedFailureMessage(actual interface{}) (message string) { if given, ok := actual.(string); ok { return fmt.Sprintf("Expected\n%s\nnot to look like\n%s\n%s", prepare(given), matcher.expected, findDifference(given, matcher.expected)) } return fmt.Sprintf("Expected\n%#v\nnot to look like\n%s", actual, matcher.expected) } func prepare(s string) string { return dedent(strings.Trim(s, "\n")) } func findDifference(a string, b string) string { aLines := strings.Split(whitespaceReplacer.Replace(prepare(a)), "\n") bLines := strings.Split(whitespaceReplacer.Replace(prepare(b)), "\n") minLines := len(aLines) if len(bLines) < minLines { minLines = len(bLines) } for i, aLine := range aLines[:minLines] { bLine := bLines[i] if aLine == bLine { continue } return fmt.Sprintf("Difference:\n%s\n%s", aLine, bLine) } return fmt.Sprintf("Remaining lines:\n%s\nAnd:\n%s", strings.Join(aLines[minLines:], "↵"), strings.Join(bLines[minLines:], "↵")) } func dedent(s string) string { shortestIndent := len(s) lines := strings.Split(s, "\n") // First pass to find the longest run of whitespace. firstLineWithText := len(lines) - 1 lastLineWithText := 0 for i, line := range lines { indentSize := 0 hasText := false for _, c := range line { if c == ' ' || c == '\t' { indentSize++ } else { hasText = true break } } if !hasText { continue } if i < firstLineWithText { firstLineWithText = i } if i > lastLineWithText { lastLineWithText = i } if indentSize < shortestIndent { shortestIndent = indentSize } } result := []string{} for _, line := range lines[firstLineWithText : lastLineWithText+1] { start := shortestIndent if start > len(line) { start = len(line) } result = append(result, strings.TrimRight(line[start:], "\t ")) } return strings.Join(result, "\n") }
spec/matchers/looklike.go
0.650023
0.436202
looklike.go
starcoder
package main import ( "fmt" "math" "strconv" "strings" ) /** --- Day 9: Encoding Error --- With your neighbor happily enjoying their video game, you turn your attention to an open data port on the little screen in the seat in front of you. Though the port is non-standard, you manage to connect it to your computer through the clever use of several paperclips. Upon connection, the port outputs a series of numbers (your puzzle input). The data appears to be encrypted with the eXchange-Masking Addition System (XMAS) which, conveniently for you, is an old cypher with an important weakness. XMAS starts by transmitting a preamble of 25 numbers. After that, each number you receive should be the sum of any two of the 25 immediately previous numbers. The two numbers will have different values, and there might be more than one such pair. For example, suppose your preamble consists of the numbers 1 through 25 in a random order. To be valid, the next number must be the sum of two of those numbers: 26 would be a valid next number, as it could be 1 plus 25 (or many other pairs, like 2 and 24). 49 would be a valid next number, as it is the sum of 24 and 25. 100 would not be valid; no two of the previous 25 numbers sum to 100. 50 would also not be valid; although 25 appears in the previous 25 numbers, the two numbers in the pair must be different. Suppose the 26th number is 45, and the first number (no longer an option, as it is more than 25 numbers ago) was 20. Now, for the next number to be valid, there needs to be some pair of numbers among 1-19, 21-25, or 45 that add up to it: 26 would still be a valid next number, as 1 and 25 are still within the previous 25 numbers. 65 would not be valid, as no two of the available numbers sum to it. 64 and 66 would both be valid, as they are the result of 19+45 and 21+45 respectively. Here is a larger example which only considers the previous 5 numbers (and has a preamble of length 5): 35 20 15 25 47 40 62 55 65 95 102 117 150 182 127 219 299 277 309 576 In this example, after the 5-number preamble, almost every number is the sum of two of the previous 5 numbers; the only number that does not follow this rule is 127. The first step of attacking the weakness in the XMAS data is to find the first number in the list (after the preamble) which is not the sum of two of the 25 numbers before it. What is the first number that does not have this property? Your puzzle answer was 257342611. */ var input []int func init_data() []int { contents := getFilesContents("day09.input") data := strings.Split(contents, "\n") list := []int{} for _, v := range data { asint, _ := strconv.Atoi(v) list = append(list, asint) } return list } func day9_part1() { list := init_data() find_fist_invalid(list, 25) } func find_fist_invalid(list []int, preamble int) int { for i := preamble; i < len(list); i++ { res, _ := find_valid(list[i], list[i-preamble:i]) if !res { // fmt.Println("found invalid", list[i]) return list[i] } // fmt.Println("valid", list[i]) } return 0 } func find_valid(candidate int, list []int) (bool, int) { found := false for _, a := range list { for _, b := range list { if a+b == candidate { found = true break } if found { break } } } return found, candidate } /** --- Part Two --- The final step in breaking the XMAS encryption relies on the invalid number you just found: you must find a contiguous set of at least two numbers in your list which sum to the invalid number from step 1. Again consider the above example: 35 20 15 25 47 40 62 55 65 95 102 117 150 182 127 219 299 277 309 576 In this list, adding up all of the numbers from 15 through 40 produces the invalid number from step 1, 127. (Of course, the contiguous set of numbers in your actual list might be much longer.) To find the encryption weakness, add together the smallest and largest number in this contiguous range; in this example, these are 15 and 47, producing 62. What is the encryption weakness in your XMAS-encrypted list of numbers? Your puzzle answer was 35602097. */ func day9_part2() { list := init_data() invalid := find_fist_invalid(list, 25) for i := 0; i < len(list); i++ { sum, smallest, largest := add_to_invalid(list, invalid, i) if sum == invalid { fmt.Println("found it", smallest, largest, "Result", smallest+largest) break } } } func add_to_invalid(list []int, invalid int, start int) (int, int, int) { sum := 0 i := 0 smallest := 9999999999.0 largest := 0.0 for sum < invalid { // fmt.Print(list[start+i], " + ") sum += list[start+i] smallest = math.Min(float64(list[start+i]), float64(smallest)) largest = math.Max(float64(list[start+i]), float64(largest)) i++ } // fmt.Println("ended at", sum, "after", i, "attempts") return sum, int(smallest), int(largest) }
day09.go
0.606498
0.600569
day09.go
starcoder
package geom //MultiPoint is a collection of two-dimensional geometries representing points type MultiPoint []Point //MultiPointZ is a collection of three-dimensional geometries representing points type MultiPointZ []PointZ //MultiPointM is a collection of two-dimensional geometries representing points, with an additional value defined on each point type MultiPointM []PointM //MultiPointZM is a collection of three-dimensional geometries representing points, with an additional value defined on each point type MultiPointZM []PointZM //Envelope returns an envelope around the multi-point func (c MultiPoint) Envelope() *Envelope { e := NewEnvelope() for _, g := range c { e.Extend(g.Envelope()) } return e } //Envelope returns an envelope around the multi-point func (c MultiPointZ) Envelope() *Envelope { e := NewEnvelope() for _, g := range c { e.Extend(g.Envelope()) } return e } //EnvelopeZ returns an envelope around the multi-point func (c MultiPointZ) EnvelopeZ() *EnvelopeZ { e := NewEnvelopeZ() for _, g := range c { e.Extend(g.EnvelopeZ()) } return e } //Envelope returns an envelope around the multi-point func (c MultiPointM) Envelope() *Envelope { e := NewEnvelope() for _, g := range c { e.Extend(g.Envelope()) } return e } //EnvelopeM returns an envelope around the multi-point func (c MultiPointM) EnvelopeM() *EnvelopeM { e := NewEnvelopeM() for _, g := range c { e.Extend(g.EnvelopeM()) } return e } //Envelope returns an envelope around the multi-point func (c MultiPointZM) Envelope() *Envelope { e := NewEnvelope() for _, g := range c { e.Extend(g.Envelope()) } return e } //EnvelopeZ returns an envelope around the multi-point func (c MultiPointZM) EnvelopeZ() *EnvelopeZ { e := NewEnvelopeZ() for _, g := range c { e.Extend(g.EnvelopeZ()) } return e } //EnvelopeM returns an envelope around the multi-point func (c MultiPointZM) EnvelopeM() *EnvelopeM { e := NewEnvelopeM() for _, g := range c { e.Extend(g.EnvelopeM()) } return e } //EnvelopeZM returns an envelope around the multi-point func (c MultiPointZM) EnvelopeZM() *EnvelopeZM { e := NewEnvelopeZM() for _, g := range c { e.Extend(g.EnvelopeZM()) } return e } //Clone returns a deep copy of the multi-point func (c MultiPoint) Clone() Geometry { return &c } //Clone returns a deep copy of the multi-point func (c MultiPointZ) Clone() Geometry { return &c } //Clone returns a deep copy of the multi-point func (c MultiPointM) Clone() Geometry { return &c } //Clone returns a deep copy of the multi-point func (c MultiPointZM) Clone() Geometry { return &c } //Iterate walks over the points (and can modify in situ) the multi-point func (c MultiPoint) Iterate(f func([]Point) error) error { return f(c) } //Iterate walks over the points (and can modify in situ) the multi-point func (c MultiPointZ) Iterate(f func([]Point) error) error { points := make([]Point, len(c)) for i := range c { points[i] = c[i].Point } err := f(points) for i := range c { c[i].Point = points[i] } return err } //Iterate walks over the points (and can modify in situ) the multi-point func (c MultiPointM) Iterate(f func([]Point) error) error { points := make([]Point, len(c)) for i := range c { points[i] = c[i].Point } err := f(points) for i := range c { c[i].Point = points[i] } return err } //Iterate walks over the points (and can modify in situ) the multi-point func (c MultiPointZM) Iterate(f func([]Point) error) error { points := make([]Point, len(c)) for i := range c { points[i] = c[i].Point } err := f(points) for i := range c { c[i].Point = points[i] } return err }
multipoint.go
0.871584
0.680132
multipoint.go
starcoder
package dax import ( math "github.com/dlespiau/dax/math" ) // Color represents a color encoded in RGBA. type Color struct { R, G, B, A float32 } // FromRGBA initializes a color from (r,g,b,a) values. Components should be // between 0 and 1. func (color *Color) FromRGBA(r, g, b, a float32) { color.R = r color.G = g color.B = b color.A = a } // FromRGB initializes a color from (r,g,b) values. Components should be // between 0 and 1. The alpha is initiazed to 1 (fully opaque). func (color *Color) FromRGB(r, g, b float32) { color.FromRGBA(r, g, b, 1.0) } func u8toF(x uint8) float32 { return float32(x) / 255. } // FromRGBAu8 initializes a color from (r,g,b,a) values. Components should be // between 0 and 255. func (color *Color) FromRGBAu8(r, g, b, a uint8) { color.FromRGBA(u8toF(r), u8toF(g), u8toF(b), u8toF(a)) } // FromRGBu8 initializes a color from (r,g,b) values. Components should be // between 0 and 255. The alpha is initiazed to 1 (ie 255, fully opaque). func (color *Color) FromRGBu8(r, g, b uint8) { color.FromRGBAu8(r, g, b, 255) } // XXX: The RGB <-> HSL functions could do with some benchmarking and ideas // from: http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv func hue2rgb(p, q, t float32) float32 { if t < 0 { t++ } if t > 1 { t-- } if t < 1./6 { return p + (q-p)*6*t } if t < 1./2 { return q } if t < 2./3 { return p + (q-p)*(2./3-t)*6 } return p } // FromHSL initializes a color from (h,s,l) values. h, s, l are between 0 and 1. // Conversion formula is adapted from: // http://en.wikipedia.org/wiki/HSL_color_space func (color *Color) FromHSL(h, s, l float32) { color.A = 1.0 if s == 0 { // achromatic color.R = l color.G = l color.B = l return } var q float32 if l < 0.5 { q = l * (1 + s) } else { q = l + s - l*s } p := 2*l - q color.R = hue2rgb(p, q, h+1./3) color.G = hue2rgb(p, q, h) color.B = hue2rgb(p, q, h-1./3) } // ToHSL converts a color to HSL. Returned (h,s,l) components are between 0 and // 1. Conversion formula adapted from: // http://en.wikipedia.org/wiki/HSL_color_space. func (color *Color) ToHSL() (h, s, l float32) { r := color.R g := color.G b := color.B max := math.Max(r, math.Max(g, b)) min := math.Min(r, math.Min(g, b)) h = float32(0.0) s = float32(0.0) l = (max + min) / 2 if max == min { return } d := max - min if l > 0.5 { s = d / (2 - max - min) } else { s = d / (max + min) } switch max { case r: var k float32 if g < b { k = float32(6) } else { k = float32(0) } h = (g-b)/d + k case g: h = (b-r)/d + 2 case b: h = (r-g)/d + 4 } h /= 6 return } // Vec4 returns a Vec4 with the 4 components of the color. func (color *Color) Vec4() math.Vec4 { return math.Vec4{color.R, color.G, color.B, color.A} }
color.go
0.850841
0.597461
color.go
starcoder
package math import ( "errors" "math" ) // checkHistograms check if the histograms are correct. func checkHistograms(hist1, hist2 []float64) error { if len(hist1) == 0 || len(hist2) == 0 { return errors.New("Could not compare the histograms. The histogram is empty.") } if len(hist1) != len(hist2) { return errors.New("Could not compare the histograms. The slices have different sizes.") } return nil } // chiSquare calculates the distance between two histograms using // the chi square statistic. // x^2 = \sum_{i=1}^{n}\frac{(hist1_{i} - hist2_{i})^2}{hist1_{i}} // References: // http://file.scirp.org/Html/8-72278_30995.htm // https://www.google.com/patents/WO2007080817A1?cl=en func ChiSquare(hist1, hist2 []float64) (float64, error) { // Check the histogram sizes if err := checkHistograms(hist1, hist2); err != nil { return 0.0, err } var sum float64 for index := 0; index < len(hist1); index++ { numerator := math.Pow(hist1[index]-hist2[index], 2) denominator := hist1[index] sum += numerator / denominator } return sum, nil } // EuclideanDistance calculates the euclidean distance between two histograms // by the following formula: // D = \sqrt{\sum_{i=1}^{n}(hist1_{i} - hist2_{i})^2} // Reference: http://www.pbarrett.net/techpapers/euclid.pdf func EuclideanDistance(hist1, hist2 []float64) (float64, error) { // Check the histogram sizes if err := checkHistograms(hist1, hist2); err != nil { return 0.0, err } var sum float64 for index := 0; index < len(hist1); index++ { sum += math.Pow(hist1[index]-hist2[index], 2) } return math.Sqrt(sum), nil } // NormalizedEuclideanDistance calculates the euclidean distance normalized. // D = \sqrt{\sum_{i=1}^{n} \frac{(hist1_{i} - hist2_{i})^2}{n}} // Reference: // http://www.pbarrett.net/techpapers/euclid.pdf func NormalizedEuclideanDistance(hist1, hist2 []float64) (float64, error) { // Check the histogram sizes if err := checkHistograms(hist1, hist2); err != nil { return 0.0, err } var sum float64 n := float64(len(hist1)) for index := 0; index < len(hist1); index++ { sum += math.Pow(hist1[index]-hist2[index], 2) / n } return math.Sqrt(sum), nil } // AbsoluteValue calculates the absolute values between two histograms. // D = \sum_{i=1}^{n} \left | hist1_{i} - hist2_{i} \right | func AbsoluteValue(hist1, hist2 []float64) (float64, error) { // Check the histogram sizes if err := checkHistograms(hist1, hist2); err != nil { return 0.0, err } var sum float64 for index := 0; index < len(hist1); index++ { sum += math.Abs(hist1[index] - hist2[index]) } return sum, nil }
math/math.go
0.84338
0.524395
math.go
starcoder
package pkg import ( "fmt" "golang.org/x/exp/constraints" "math" ) const strNilNode = "_" type BinaryTree[T constraints.Ordered] struct { root *TreeNode[T] } func (b *BinaryTree[T]) Insert(value T) { if b.root == nil { b.root = &TreeNode[T]{Value: value} return } treeNodeAdd(b.root, value) } func (b *BinaryTree[T]) Exists(value T) bool { if b.root == nil { return false } return treeNodeExists(b.root, value) } func (b *BinaryTree[T]) Delete(value T) bool { if b.root == nil { return false } var ok bool b.root, ok = deleteNode(b.root, value) return ok } func (b *BinaryTree[T]) MaxDepth() int { if b.root == nil { return 0 } return maxDepth(b.root) } func (b *BinaryTree[T]) Reverse() { if b.root == nil { return } reverse(b.root) } func (b *BinaryTree[T]) MaxValue() (T, bool) { if b.root == nil { var zero T return zero, false } return maxValue(b.root), true } func (b *BinaryTree[T]) MinValue() (T, bool) { if b.root == nil { var zero T return zero, false } return minValue(b.root), true } func (b *BinaryTree[T]) DFSPreOrder() []T { var result []T if b.root == nil { return result } return dfsPreOrder(b.root) } func (b *BinaryTree[T]) DFSInOrder() []T { var result []T if b.root == nil { return result } return dfsInOrder(b.root) } func (b *BinaryTree[T]) DFSPostOrder() []T { var result []T if b.root == nil { return result } return dfsPostOrder(b.root) } func (b *BinaryTree[T]) BFSLevelOrder() []T { var result []T if b.root == nil { return result } nodes := []TreeNode[T]{*b.root} return bfsLevelOrder(nodes) } func (b *BinaryTree[T]) BFSLevelOrderRecursive() []T { var result []T if b.root == nil { return result } nodes := []TreeNode[T]{*b.root} return bfsLevelOrderRecursive(nodes) } type TreeNode[T constraints.Ordered] struct { Left *TreeNode[T] Value T Right *TreeNode[T] } func treeNodeAdd[T constraints.Ordered](node *TreeNode[T], value T) { if node.Left == nil && value < node.Value { node.Left = &TreeNode[T]{Value: value} } if node.Right == nil && value > node.Value { node.Right = &TreeNode[T]{Value: value} } if value < node.Value { treeNodeAdd(node.Left, value) } if value > node.Value { treeNodeAdd(node.Right, value) } } func treeNodeExists[T constraints.Ordered](node *TreeNode[T], value T) bool { if node == nil { return false } if value == node.Value { return true } if value < node.Value { return treeNodeExists(node.Left, value) } if value > node.Value { return treeNodeExists(node.Right, value) } return false } func maxDepth[T constraints.Ordered](node *TreeNode[T]) int { if node == nil { return 0 } r := maxDepth(node.Right) + 1 l := maxDepth(node.Left) + 1 max := math.Max(float64(r), float64(l)) return int(max) } func reverse[T constraints.Ordered](node *TreeNode[T]) { if node == nil { return } node.Right, node.Left = node.Left, node.Right reverse(node.Left) reverse(node.Right) } func maxValue[T constraints.Ordered](node *TreeNode[T]) T { max := node.Value if node.Right != nil { if r := maxValue(node.Right); r > max { max = r } } if node.Left != nil { if l := maxValue(node.Left); l > max { max = l } } return max } func minValue[T constraints.Ordered](node *TreeNode[T]) T { max := node.Value if node.Right != nil { if r := minValue(node.Right); r < max { max = r } } if node.Left != nil { if l := minValue(node.Left); l < max { max = l } } return max } func dfsPreOrder[T constraints.Ordered](node *TreeNode[T]) []T { var result []T if node == nil { return result } result = append(result, node.Value) result = append(result, dfsPreOrder(node.Left)...) result = append(result, dfsPreOrder(node.Right)...) return result } func dfsInOrder[T constraints.Ordered](node *TreeNode[T]) []T { var result []T if node == nil { return result } result = append(result, dfsInOrder(node.Left)...) result = append(result, node.Value) result = append(result, dfsInOrder(node.Right)...) return result } func dfsPostOrder[T constraints.Ordered](node *TreeNode[T]) []T { var result []T if node == nil { return result } result = append(result, dfsPostOrder(node.Left)...) result = append(result, dfsPostOrder(node.Right)...) result = append(result, node.Value) return result } func bfsLevelOrder[T constraints.Ordered](queue []TreeNode[T]) []T { var result []T for len(queue) > 0 { result = append(result, queue[0].Value) if queue[0].Left != nil { queue = append(queue, *queue[0].Left) } if queue[0].Right != nil { queue = append(queue, *queue[0].Right) } queue = queue[1:] } return result } func bfsLevelOrderRecursive[T constraints.Ordered](queue []TreeNode[T]) []T { var result []T if len(queue) == 0 { return result } cur := queue[0] result = append(result, cur.Value) if cur.Left != nil { queue = append(queue, *cur.Left) } if cur.Left != nil { queue = append(queue, *cur.Right) } if len(queue) > 0 { return append(result, bfsLevelOrderRecursive(queue[1:])...) } return result } func deleteNode[T constraints.Ordered](node *TreeNode[T], value T) (*TreeNode[T], bool) { if node == nil { return node, false } var ok bool if value < node.Value { node.Left, ok = deleteNode(node.Left, value) return node, ok } if value > node.Value { node.Right, ok = deleteNode(node.Right, value) return node, ok } if node.Left == nil && node.Right == nil { return nil, true } if node.Left == nil { return node.Right, true } if node.Right == nil { return node.Left, true } node.Value = minValue(node.Right) node.Right, _ = deleteNode(node.Right, node.Value) return node, true } func (t *TreeNode[T]) String() string { if t == nil { return "nil" } left := strNilNode if t.Left != nil { left = t.Left.String() } right := strNilNode if t.Right != nil { right = t.Right.String() } return fmt.Sprintf("(%s %v %s)", left, t.Value, right) }
spells/data-structures/pkg/binarytree.go
0.692226
0.502625
binarytree.go
starcoder
package gen import ( "fmt" "sort" "github.com/badvassal/wllib/gen/wlerr" ) // Point represents 2d coordinates or a width,height pair. type Point struct { X int Y int } // ExtractBlob copies a subsequence of bytes from a larger sequence. off is // the offset within section to start the copy. end is the offset at which to // end the copy, or -1 to copy until the end of section. func ExtractBlob(section []byte, off int, end int) ([]byte, error) { if off < 0 { return nil, fmt.Errorf("invalid offset: %d", off) } if end < 0 { end = len(section) } size := end - off if size < 0 { return nil, wlerr.Errorf( "data has negative length: off=%d end=%d", off, end) } if size == 0 { return nil, nil } if end > len(section) { return nil, wlerr.Errorf( "data extends beyond end of section: data=%d section=%d", end, len(section)) } return section[off:end], nil } // ReadString parses a null-terminated UTF8 string from a sequence of bytes. func ReadString(b []byte) (string, error) { for i, c := range b { if c == 0 { return string(b[:i]), nil } } return "", wlerr.Errorf("failed to parse string: no null terminator") } // ReadString parses a little-endian uint16 from a sequence of bytes. func ReadUint16(b []byte) (int, error) { if len(b) != 2 { return 0, wlerr.Errorf( "cannot decode uint16: wrong number of bytes: have=%d want=2", len(b)) } return int(b[1])<<8 + int(b[0]), nil } // ReadString parses a little-endian uint24 from a sequence of bytes. func ReadUint24(b []byte) (int, error) { if len(b) != 3 { return 0, wlerr.Errorf( "cannot decode uint24: wrong number of bytes: have=%d want=3", len(b)) } return int(b[2])<<16 + int(b[1])<<8 + int(b[0]), nil } // ReadPointers reads the pointers at the start of a table. These pointers are // offsets of data contained by the table. The offsets are relative to the // start of the table baseOff is the offset of the start of the table relative // to the start of the MSQ block's secure section. It returns the set of // pointers and its size, in bytes. func ReadPointers(data []byte, baseOff int) ([]int, int, error) { off := 0 readPtr := func() (int, error) { b, err := ExtractBlob(data, off, off+2) if err != nil { return 0, err } p, err := ReadUint16(b) if err != nil { return 0, err } off += 2 return p, nil } var firstPtr int var ptrAreaLen int var ptrs []int for { p, err := readPtr() if err != nil { return nil, 0, wlerr.ToWLError(err) } ptrs = append(ptrs, p) if p != 0 { firstPtr = p ptrAreaLen = p - baseOff break } } if ptrAreaLen < 0 { return nil, 0, wlerr.Errorf( "pointer area has invalid size: p=%d have=%d want>=0", firstPtr, ptrAreaLen) } if ptrAreaLen%2 != 0 { return nil, 0, wlerr.Errorf( "pointer area has invalid size: have=%d want%%2: ptrs=%+v baseOff=%d", ptrAreaLen, ptrs, baseOff) } numPtrs := ptrAreaLen / 2 for i := len(ptrs); i < numPtrs; i++ { p, err := readPtr() if err != nil { return nil, 0, wlerr.ToWLError(err) } ptrs = append(ptrs, p) } return ptrs, firstPtr, nil } // WriteUint16 converts a uint16 to its byte representation (little endian). func WriteUint16(u16 uint16) []byte { return []byte{ byte(u16 & 0xff), byte(u16 >> 8), } } // WriteUint16 converts the lower 24 bits of an int to their byte // representation (little endian). If any higher bits are set they are // ignored. func WriteUint24(u24 int) []byte { return []byte{ byte((u24 & 0xff) >> 0), byte((u24 & 0xff00) >> 8), byte((u24 & 0xff0000) >> 16), } } // BoolToByte converts a boolean to its byte representation // (false=0x00, true=0x01). func BoolToByte(b bool) byte { if b { return byte(1) } else { return byte(0) } } // SortedUniqueInts sorts a slice of ints and removes duplicates. func SortedUniqueInts(vals []int) []int { m := map[int]struct{}{} for _, v := range vals { m[v] = struct{}{} } var s []int for k, _ := range m { s = append(s, k) } sort.Ints(s) return s } // NextInt searches for the "next" value from a slice of sorted unique // integers. The "next" value is the first value greater than cur. If no such // next value is present in the list, max is returned instead. func NextInt(cur int, sortedUnique []int, max int) int { for i := 0; i < len(sortedUnique)-1; i++ { if sortedUnique[i] >= cur { return sortedUnique[i+1] } } return max } // Assert panics if the given condition is false. func Assert(expr bool) { if !expr { panic("ASSERTION FAILED") } } func FilterIDs(numIDs int, shouldKeep func(id int) bool) []int { ids := make([]int, 0, numIDs) for i := 0; i < numIDs; i++ { if shouldKeep(i) { ids = append(ids, i) } } return ids }
gen/gen.go
0.642769
0.441252
gen.go
starcoder
package bitmaptable import ( "errors" "github.com/boljen/go-bitmap" ) // These are errors that can be returned by the Bitmaptable. var ( ErrIllegalIndex = errors.New("Bitmaptable: Illegal identifier or position") ErrIllegalWidth = errors.New("Bitmaptable: Illegal value width, must be between 1 and 64") ) // Bitmaptable is the basic bitmap table on which all other tables are built. // The bitmap table stores column-based bit information on a per-row basis. type Bitmaptable interface { // Data returns the underlying data of the bitmap. // If copy is true it will copy all the data into a new byteslice. Data(copy bool) []byte // Rows returns the amount of rows inside this bitmap table. Rows() int // Columns returns the amount of columns inside this bitmap table. Columns() int // Get gets the value for the provided row and column tuple. Get(row int, column int) (bool, error) // Set sets the value for the provided row and column tuple. Set(row int, column int, value bool) error } // New creates a new Bitmaptable instance. // Remember that this will allocate rows * columns bits of memory. // There can be 2^64 rows and 2^16 columns per row, theoretically. func New(rows, columns int) Bitmaptable { return newNTS(rows, columns) } // NewTS creates a new thread-safe Bitmaptable instance. func NewTS(rows, columns int) Bitmaptable { return newTS(rows, columns) } func newNTS(rows, columns int) *bitmaptable { return &bitmaptable{ rows: rows, columns: columns, bitmap: bitmap.New(columns * rows), } } type bitmaptable struct { rows int // Amount of rows. columns int // Amount of columns per row. bitmap bitmap.Bitmap // The actual bitmap } // Rows implements Bitmaptable.Rows func (b *bitmaptable) Rows() int { return b.rows } // Columns implements Bitmaptable.Columns func (b *bitmaptable) Columns() int { return b.columns } // Data implements Bitmaptable.Data func (b *bitmaptable) Data(c bool) []byte { return b.bitmap.Data(c) } // Get implements Bitmaptable.Get func (b *bitmaptable) Get(row int, column int) (bool, error) { if column >= b.columns || row >= b.rows { return false, ErrIllegalIndex } return b.bitmap.Get(row*b.columns + column), nil } // Set implements Bitmaptable.Set func (b *bitmaptable) Set(row int, column int, value bool) error { if column >= int(b.columns) || row >= int(b.rows) { return ErrIllegalIndex } b.bitmap.Set(row*b.columns+column, value) return nil }
bitmaptable.go
0.747432
0.564098
bitmaptable.go
starcoder
package lib import ( "log" "math/rand" "net/http" "time" ) // TwoChoice struct contains: // - A slice of node pointers // - A set of indexes to healthy nodes (as a map) // - A set of indexes to unhealthy ndoes (as a map) type TwoChoice struct { Nodes []*Node HealthyNodes map[int]bool UnhealthyNodes map[int]bool } // NewTwoChoice creates a new TwoChoice load balancer func NewTwoChoice(nodes []*Node) *TwoChoice { if len(nodes) < 3 { log.Fatalf("At least 3 nodes are required for TwoChoice, %d found", len(nodes)) } tc := TwoChoice{nodes, make(map[int]bool), make(map[int]bool)} rand.Seed(time.Now().UTC().UnixNano()) for i, n := range tc.Nodes { n.SetHealthy() tc.HealthyNodes[i] = true } healthyNodesGauge.Set(float64(len(nodes))) totalNodesGauge.Set(float64(len(nodes))) tc.AsyncHealthChecks() return &tc } // AsyncHealthChecks performs health checks in the background at an interval // set by asyncHealthChecksTimeSeconds. func (tc *TwoChoice) AsyncHealthChecks() { go func() { for { log.Println("Performing async health checks") tc.healthChecks() time.Sleep(asyncHealthChecksTimeSeconds * time.Second) } }() } func (tc *TwoChoice) healthChecks() { for i, n := range tc.Nodes { if n.CheckHealth() { tc.idempotentRecoverNode(n, i) } else { tc.idempotentDeactivateNode(n, i) } } log.Printf("%d out of %d nodes are healthy", len(tc.HealthyNodes), len(tc.Nodes)) } // Handler selects a node via random two choice and passes the request to the // selected node. See https://www.nginx.com/blog/nginx-power-of-two-choices-load-balancing-algorithm/ func (tc *TwoChoice) Handler(w http.ResponseWriter, r *http.Request) { nodeKey := tc.selectNodeKey() node := tc.Nodes[nodeKey] log.Printf("Handling request to %s:%s. Active Connections: %d. Method: TwoChoice.\n", node.Address, node.Port, node.ActiveConnections) switch status := node.Handler(w, r); { case status >= 500: log.Printf("Node %s:%s failed to process request. Status: %d.\n", node.Address, node.Port, status) tc.idempotentDeactivateNode(node, nodeKey) processedTotal.WithLabelValues("5xx", node.Address).Inc() case status >= 400: tc.idempotentRecoverNode(node, nodeKey) processedTotal.WithLabelValues("4xx", node.Address).Inc() case status >= 300: tc.idempotentRecoverNode(node, nodeKey) processedTotal.WithLabelValues("3xx", node.Address).Inc() case status >= 200: tc.idempotentRecoverNode(node, nodeKey) processedTotal.WithLabelValues("2xx", node.Address).Inc() default: tc.idempotentRecoverNode(node, nodeKey) processedTotal.WithLabelValues("1xx", node.Address).Inc() } } func (tc *TwoChoice) selectNodeKey() int { var nodePool map[int]bool // If we have less than 2 healthy nodes, serve to the unhealthy node pool. if len(tc.HealthyNodes) >= 2 { nodePool = tc.HealthyNodes } else { nodePool = tc.UnhealthyNodes } keys := make([]int, len(nodePool)) i := 0 for k := range nodePool { keys[i] = k i++ } first := keys[rand.Intn(len(keys))] second := keys[rand.Intn(len(keys))] for first == second { second = keys[rand.Intn(len(keys))] } log.Printf( "TwoChoice Candidates: %s:%s (ActiveConnections: %d), %s:%s (ActiveConnections: %d)", tc.Nodes[first].Address, tc.Nodes[first].Port, tc.Nodes[first].ActiveConnections, tc.Nodes[second].Address, tc.Nodes[second].Port, tc.Nodes[second].ActiveConnections, ) if tc.Nodes[first].ActiveConnections < tc.Nodes[second].ActiveConnections { return first } return second } func (tc *TwoChoice) idempotentRecoverNode(n *Node, key int) { if n.IsUnhealthy() { tc.HealthyNodes[key] = true delete(tc.UnhealthyNodes, key) n.SetHealthy() healthyNodesGauge.Inc() } } func (tc *TwoChoice) idempotentDeactivateNode(n *Node, key int) { if n.IsHealthy() { tc.UnhealthyNodes[key] = true delete(tc.HealthyNodes, key) n.SetUnhealthy() healthyNodesGauge.Dec() } }
lib/twochoice.go
0.556159
0.40539
twochoice.go
starcoder
package tree import ( "fmt" "math" ) //Node represents a node in a binary tree type BTNode struct { data int left *BTNode right *BTNode } type BinaryTree struct { root *BTNode } func NewBinaryTree() *BinaryTree { return &BinaryTree{} } //NewNode creates a new node to be inserted in bst func NewBTNode(data int) *BTNode { return &BTNode{ data: data, left: nil, right: nil, } } func (bt *BinaryTree) InsertRoot(input int) *BTNode { (*bt).root = NewBTNode(input) return bt.root } //InsertLeft inserts a left child to this given node func (node *BTNode) InsertLeft(input int) *BTNode { if node != nil { (*node).left = NewBTNode(input) return node.left } return nil } //InsertRight inserts a right child to this given node func (node *BTNode) InsertRight(input int) *BTNode { if node != nil { (*node).right = NewBTNode(input) return node.right } return nil } func (node *BTNode) IsBSTUtil(min, max int) bool { if node.data <= min || node.data > max { return false } lsubtree := true rsubtree := true if node.left != nil { lsubtree = node.left.IsBSTUtil(min, node.data) } if node.right != nil { rsubtree = node.right.IsBSTUtil(node.data, max) } return lsubtree && rsubtree } //IsBST returns true/false if a given binary tree is BST. func (bt *BinaryTree) IsBST() bool { min, max := math.MinInt16, math.MaxInt16 return bt.root.IsBSTUtil(min, max) } func (node *BTNode) LCAUtil(inp1, inp2 int) *BTNode { if (node.data == inp1) || (node.data == inp2) { return node } var ltree, rtree *BTNode if node.left != nil { ltree = node.left.LCAUtil(inp1, inp2) } if node.right != nil { rtree = node.right.LCAUtil(inp1, inp2) } if rtree != nil && ltree != nil { return node } if ltree != nil { return ltree } return rtree } //LCA returns LCA of given two nodes func (bt *BinaryTree) LCA(inp1, inp2 int) *BTNode { return bt.root.LCAUtil(inp1, inp2) } func (node *BTNode) PathWithGivenSumUtil(sumSoFar, sum int, path *([]int)) { sumSoFar += node.data (*path) = append((*path), node.data) if sumSoFar == sum { //TODO: Store path in a slice of slice or map of slices fmt.Println("Found path: ", *path) } if node.left != nil { node.left.PathWithGivenSumUtil(sumSoFar, sum, path) } if node.right != nil { node.right.PathWithGivenSumUtil(sumSoFar, sum, path) } *path = (*path)[0 : len(*path)-1] } //PathWithGivenSum will return a path with a given sum from ROOT -> any child ( not necessarily leaf ) func (bt *BinaryTree) PathWithGivenSum(sum int) { path := make([]int, 0) sumSoFar := 0 bt.root.PathWithGivenSumUtil(sumSoFar, sum, &path) }
tree/binaryTree.go
0.708717
0.420897
binaryTree.go
starcoder
package dlogproofs import ( "math/big" "github.com/xlab-si/emmy/crypto/common" "github.com/xlab-si/emmy/crypto/groups" ) // Verifies that the blinded transcript is valid. That means the knowledge of log_g1(t1), log_G2(T2) // and log_g1(t1) = log_G2(T2). Note that G2 = g2^gamma, T2 = t2^gamma where gamma was chosen // by verifier. func VerifyBlindedTranscriptEC(transcript *TranscriptEC, curve groups.ECurve, g1, t1, G2, T2 *groups.ECGroupElement) bool { group := groups.NewECGroup(curve) // check hash: hashNum := common.Hash(transcript.Alpha_1, transcript.Alpha_2, transcript.Beta_1, transcript.Beta_2) if hashNum.Cmp(transcript.Hash) != 0 { return false } // We need to verify (note that c-beta = hash(alpha11, alpha12, beta11, beta12)) // g1^(z+alpha) = (alpha11, alpha12) * t1^(c-beta) // G2^(z+alpha) = (beta11, beta12) * T2^(c-beta) left1 := group.Exp(g1, transcript.ZAlpha) right1 := group.Exp(t1, transcript.Hash) Alpha := groups.NewECGroupElement(transcript.Alpha_1, transcript.Alpha_2) right1 = group.Mul(Alpha, right1) left2 := group.Exp(G2, transcript.ZAlpha) right2 := group.Exp(T2, transcript.Hash) Beta := groups.NewECGroupElement(transcript.Beta_1, transcript.Beta_2) right2 = group.Mul(Beta, right2) return left1.Equals(right1) && left2.Equals(right2) } type TranscriptEC struct { Alpha_1 *big.Int Alpha_2 *big.Int Beta_1 *big.Int Beta_2 *big.Int Hash *big.Int ZAlpha *big.Int } func NewTranscriptEC(alpha_1, alpha_2, beta_1, beta_2, hash, zAlpha *big.Int) *TranscriptEC { return &TranscriptEC{ Alpha_1: alpha_1, Alpha_2: alpha_2, Beta_1: beta_1, Beta_2: beta_2, Hash: hash, ZAlpha: zAlpha, } } type ECDLogEqualityBTranscriptProver struct { Group *groups.ECGroup r *big.Int secret *big.Int g1 *groups.ECGroupElement g2 *groups.ECGroupElement } func NewECDLogEqualityBTranscriptProver(curve groups.ECurve) *ECDLogEqualityBTranscriptProver { group := groups.NewECGroup(curve) prover := ECDLogEqualityBTranscriptProver{ Group: group, } return &prover } // Prove that you know dlog_g1(h1), dlog_g2(h2) and that dlog_g1(h1) = dlog_g2(h2). func (prover *ECDLogEqualityBTranscriptProver) GetProofRandomData(secret *big.Int, g1, g2 *groups.ECGroupElement) (*groups.ECGroupElement, *groups.ECGroupElement) { // Set the values that are needed before the protocol can be run. // The protocol proves the knowledge of log_g1(t1), log_g2(t2) and // that log_g1(t1) = log_g2(t2). prover.secret = secret prover.g1 = g1 prover.g2 = g2 r := common.GetRandomInt(prover.Group.Q) prover.r = r a := prover.Group.Exp(prover.g1, r) b := prover.Group.Exp(prover.g2, r) return a, b } func (prover *ECDLogEqualityBTranscriptProver) GetProofData(challenge *big.Int) *big.Int { // z = r + challenge * secret z := new(big.Int) z.Mul(challenge, prover.secret) z.Add(z, prover.r) z.Mod(z, prover.Group.Q) return z } type ECDLogEqualityBTranscriptVerifier struct { Group *groups.ECGroup gamma *big.Int challenge *big.Int g1 *groups.ECGroupElement g2 *groups.ECGroupElement x1 *groups.ECGroupElement x2 *groups.ECGroupElement t1 *groups.ECGroupElement t2 *groups.ECGroupElement alpha *big.Int transcript *TranscriptEC } func NewECDLogEqualityBTranscriptVerifier(curve groups.ECurve, gamma *big.Int) *ECDLogEqualityBTranscriptVerifier { group := groups.NewECGroup(curve) if gamma == nil { gamma = common.GetRandomInt(group.Q) } verifier := ECDLogEqualityBTranscriptVerifier{ Group: group, gamma: gamma, } return &verifier } func (verifier *ECDLogEqualityBTranscriptVerifier) GetChallenge(g1, g2, t1, t2, x1, x2 *groups.ECGroupElement) *big.Int { // Set the values that are needed before the protocol can be run. // The protocol proves the knowledge of log_g1(t1), log_g2(t2) and // that log_g1(t1) = log_g2(t2). verifier.g1 = g1 verifier.g2 = g2 verifier.t1 = t1 verifier.t2 = t2 // Set the values g1^r1 and g2^r2. verifier.x1 = x1 verifier.x2 = x2 alpha := common.GetRandomInt(verifier.Group.Q) beta := common.GetRandomInt(verifier.Group.Q) // alpha1 = g1^r * g1^alpha * t1^beta // beta1 = (g2^r * g2^alpha * t2^beta)^gamma alpha1 := verifier.Group.Exp(verifier.g1, alpha) alpha1 = verifier.Group.Mul(verifier.x1, alpha1) tmp := verifier.Group.Exp(verifier.t1, beta) alpha1 = verifier.Group.Mul(alpha1, tmp) beta1 := verifier.Group.Exp(verifier.g2, alpha) beta1 = verifier.Group.Mul(verifier.x2, beta1) tmp = verifier.Group.Exp(verifier.t2, beta) beta1 = verifier.Group.Mul(beta1, tmp) beta1 = verifier.Group.Exp(beta1, verifier.gamma) // c = hash(alpha1, beta) + beta mod q hashNum := common.Hash(alpha1.X, alpha1.Y, beta1.X, beta1.Y) challenge := new(big.Int).Add(hashNum, beta) challenge.Mod(challenge, verifier.Group.Q) verifier.challenge = challenge verifier.transcript = NewTranscriptEC(alpha1.X, alpha1.Y, beta1.X, beta1.Y, hashNum, nil) verifier.alpha = alpha return challenge } // It receives z = r + secret * challenge. //It returns true if g1^z = g1^r * (g1^secret) ^ challenge and g2^z = g2^r * (g2^secret) ^ challenge. func (verifier *ECDLogEqualityBTranscriptVerifier) Verify(z *big.Int) (bool, *TranscriptEC, *groups.ECGroupElement, *groups.ECGroupElement) { left1 := verifier.Group.Exp(verifier.g1, z) left2 := verifier.Group.Exp(verifier.g2, z) r1 := verifier.Group.Exp(verifier.t1, verifier.challenge) r2 := verifier.Group.Exp(verifier.t2, verifier.challenge) right1 := verifier.Group.Mul(r1, verifier.x1) right2 := verifier.Group.Mul(r2, verifier.x2) // transcript [(alpha11, alpha12, beta11, beta12), hash(alpha11, alpha12, beta11, beta12), z+alpha] // however, we are actually returning: // [alpha11, alpha12, beta11, beta12, hash(alpha11, alpha12, beta11, beta12), z+alpha] z1 := new(big.Int).Add(z, verifier.alpha) verifier.transcript.ZAlpha = z1 G2 := verifier.Group.Exp(verifier.g2, verifier.gamma) T2 := verifier.Group.Exp(verifier.t2, verifier.gamma) if left1.Equals(right1) && left2.Equals(right2) { return true, verifier.transcript, G2, T2 } else { return false, nil, nil, nil } }
crypto/zkp/primitives/dlogproofs/dlog_equality_blinded_transcript_ec.go
0.681197
0.412648
dlog_equality_blinded_transcript_ec.go
starcoder
package client import ( "crypto" "fmt" "io" "math" pb "github.com/google/go-tpm-tools/proto/tpm" "github.com/google/go-tpm/tpm2" ) // NumPCRs is set to the spec minimum of 24, as that's all go-tpm supports. const NumPCRs = 24 // We hard-code SHA256 as the policy session hash algorithms. Note that this // differs from the PCR hash algorithm (which selects the bank of PCRs to use) // and the Public area Name algorithm. We also chose this for compatibility with // github.com/google/go-tpm/tpm2, as it hardcodes the nameAlg as SHA256 in // several places. Two constants are used to avoid repeated conversions. const ( SessionHashAlg = crypto.SHA256 SessionHashAlgTpm = tpm2.AlgSHA256 ) // CertifyHashAlgTpm is the hard-coded algorithm used in certify PCRs. const CertifyHashAlgTpm = tpm2.AlgSHA256 func min(a, b int) int { if a < b { return a } return b } // Get a list of selections corresponding to the TPM's implemented PCRs func implementedPCRs(rw io.ReadWriter) ([]tpm2.PCRSelection, error) { caps, moreData, err := tpm2.GetCapability(rw, tpm2.CapabilityPCRs, math.MaxUint32, 0) if err != nil { return nil, fmt.Errorf("listing implemented PCR banks: %w", err) } if moreData { return nil, fmt.Errorf("extra data from GetCapability") } sels := make([]tpm2.PCRSelection, len(caps)) for i, cap := range caps { sel, ok := cap.(tpm2.PCRSelection) if !ok { return nil, fmt.Errorf("unexpected data from GetCapability") } sels[i] = sel } return sels, nil } // ReadPCRs fetches all the PCR values specified in sel, making multiple calls // to the TPM if necessary. func ReadPCRs(rw io.ReadWriter, sel tpm2.PCRSelection) (*pb.PCRs, error) { pl := pb.PCRs{ Hash: pb.HashAlgo(sel.Hash), Pcrs: map[uint32][]byte{}, } for i := 0; i < len(sel.PCRs); i += 8 { end := min(i+8, len(sel.PCRs)) pcrSel := tpm2.PCRSelection{ Hash: sel.Hash, PCRs: sel.PCRs[i:end], } pcrMap, err := tpm2.ReadPCRs(rw, pcrSel) if err != nil { return nil, err } for pcr, val := range pcrMap { pl.Pcrs[uint32(pcr)] = val } } return &pl, nil } // ReadAllPCRs fetches all the PCR values from all implemented PCR banks. func ReadAllPCRs(rw io.ReadWriter) ([]*pb.PCRs, error) { sels, err := implementedPCRs(rw) if err != nil { return nil, err } allPcrs := make([]*pb.PCRs, len(sels)) for i, sel := range sels { allPcrs[i], err = ReadPCRs(rw, sel) if err != nil { return nil, fmt.Errorf("reading bank %x PCRs: %w", sel.Hash, err) } } return allPcrs, nil } // SealOpts specifies the PCR values that should be used for Seal(). type SealOpts struct { // Current seals data to the current specified PCR selection. Current tpm2.PCRSelection // Target predictively seals data to the given specified PCR values. Target *pb.PCRs } // UnsealOpts specifies the options that should be used for Unseal(). // Currently, it specifies the PCRs that need to pass certification in order to // successfully unseal. // CertifyHashAlgTpm is the hard-coded algorithm that must be used with // UnsealOpts. type UnsealOpts struct { // CertifyCurrent certifies that a selection of current PCRs have the same // value when sealing. CertifyCurrent tpm2.PCRSelection // CertifyExpected certifies that the TPM had a specific set of PCR values when sealing. CertifyExpected *pb.PCRs } // FullPcrSel will return a full PCR selection based on the total PCR number // of the TPM with the given hash algo. func FullPcrSel(hash tpm2.Algorithm) tpm2.PCRSelection { sel := tpm2.PCRSelection{Hash: hash} for i := 0; i < NumPCRs; i++ { sel.PCRs = append(sel.PCRs, int(i)) } return sel } func mergePCRSelAndProto(rw io.ReadWriter, sel tpm2.PCRSelection, proto *pb.PCRs) (*pb.PCRs, error) { if proto == nil || len(proto.GetPcrs()) == 0 { return ReadPCRs(rw, sel) } if len(sel.PCRs) == 0 { return proto, nil } if sel.Hash != tpm2.Algorithm(proto.Hash) { return nil, fmt.Errorf("current hash (%v) differs from target hash (%v)", sel.Hash, tpm2.Algorithm(proto.Hash)) } // At this point, both sel and proto are non-empty. // Verify no overlap in sel and proto PCR indexes. overlap := make([]int, 0) targetMap := proto.GetPcrs() for _, pcrVal := range sel.PCRs { if _, found := targetMap[uint32(pcrVal)]; found { overlap = append(overlap, pcrVal) } } if len(overlap) != 0 { return nil, fmt.Errorf("found PCR overlap: %v", overlap) } currentPcrs, err := ReadPCRs(rw, sel) if err != nil { return nil, err } for pcr, val := range proto.GetPcrs() { currentPcrs.Pcrs[pcr] = val } return currentPcrs, nil }
vendor/github.com/google/go-tpm-tools/client/pcr.go
0.602062
0.421433
pcr.go
starcoder
package spritenik // code and blog from https://github.com/jakesgordon/bin-packing func NewNode(name string, width, height int) *Node { return &Node{Key: name, Width: width, Height: height} } type Node struct { Key string Width int Height int X int Y int Used bool Right *Node Down *Node } type GrowingPacker struct { root *Node } func (p *GrowingPacker) Fit(blocks []*Node) { length := len(blocks) width, height := 0, 0 if length > 0 { width, height = blocks[0].Width, blocks[0].Height } p.root = &Node{X: 0, Y: 0, Width: width, Height: height} for i := 0; i < length; i++ { block := blocks[i] node := findNode(p.root, block.Width, block.Height) if node != nil { fit := splitNode(node, block.Width, block.Height) block.X = fit.X block.Y = fit.Y continue } fit := p.growNode(block.Width, block.Height) block.X = fit.X block.Y = fit.Y } } func findNode(root *Node, width, height int) *Node { if root.Used { n := findNode(root.Right, width, height) if n != nil { return n } return findNode(root.Down, width, height) } if (width <= root.Width) && (height <= root.Height) { return root } return nil } func splitNode(node *Node, width, height int) *Node { node.Used = true node.Down = &Node{X: node.X, Y: node.Y + height, Width: node.Width, Height: node.Height - height} node.Right = &Node{X: node.X + width, Y: node.Y, Width: node.Width - width, Height: height} return node } func (p *GrowingPacker) growNode(width, height int) *Node { canGrowDown := width <= p.root.Width canGrowRight := height <= p.root.Height shouldGrowRight := canGrowRight && (p.root.Height >= (p.root.Width + width)) // attempt to keep square-ish by growing right when height is much greater than width shouldGrowDown := canGrowDown && (p.root.Width >= (p.root.Height + height)) // attempt to keep square-ish by growing down when width is much greater than height if shouldGrowRight { return p.growRight(width, height) } else if shouldGrowDown { return p.growDown(width, height) } else if canGrowRight { return p.growRight(width, height) } else if canGrowDown { return p.growDown(width, height) } return nil // need to ensure sensible root starting size to avoid this happening } func (p *GrowingPacker) growDown(width, height int) *Node { p.root = &Node{ Used: true, X: 0, Y: 0, Width: p.root.Width, Height: p.root.Height + height, Down: &Node{X: 0, Y: p.root.Height, Width: p.root.Width, Height: height}, Right: p.root, } node := findNode(p.root, width, height) if node != nil { return splitNode(node, width, height) } return nil } func (p *GrowingPacker) growRight(width, height int) *Node { p.root = &Node{ Used: true, X: 0, Y: 0, Width: p.root.Width + width, Height: p.root.Height, Right: &Node{X: p.root.Width, Y: 0, Width: width, Height: p.root.Height}, Down: p.root, } node := findNode(p.root, width, height) if node != nil { return splitNode(node, width, height) } return nil }
growing_packer.go
0.705176
0.560734
growing_packer.go
starcoder
package main func parsePlayer(b *Buffer) { checkVers(b, 1, "Player") b.GetInt32le() // planetID b.GetFloat32() // position.x b.GetFloat32() // position.y b.GetFloat32() // uPosition.z b.GetFloat64() // uPosition.x b.GetFloat64() // uPosition.y b.GetFloat64() // uPosition.z b.GetFloat32() // uRotation.x b.GetFloat32() // uRotation.y b.GetFloat32() // uRotation.z b.GetFloat32() // uRotation.w b.GetInt32le() // movementState b.GetFloat32() // warpState b.GetBoolean() // warpCommand b.GetFloat64() // uVelocity.x b.GetFloat64() // uVelocity.y b.GetFloat64() // uVelocity.z b.GetInt32le() // inhandItemID b.GetInt32le() // inhandItemCount parseMecha(b) parseStorageComponent(b) parsePlayerNavigation(b) b.GetInt32le() // sandCount } func parseMecha(b *Buffer) { checkVers(b, 0, "Mecha") b.GetFloat64() // coreEnergyCap b.GetFloat64() // coreEnergy b.GetFloat64() // corePowerGen b.GetFloat64() // reactorPowerGen b.GetFloat64() // reactorEnergy b.GetInt32le() // reactorItemID // reactorStorage parseStorageComponent(b) // warpStorage parseStorageComponent(b) b.GetFloat64() // walkPower b.GetFloat64() // jumpPower b.GetFloat64() // thrustPowerPerAcc = r.ReadDouble(); b.GetFloat64() // warpKeepingPowerPerSpeed = r.ReadDouble(); b.GetFloat64() // warpStartPowerPerSpeed = r.ReadDouble(); b.GetFloat64() // miningPower = r.ReadDouble(); b.GetFloat64() // replicatePower = r.ReadDouble(); b.GetFloat64() // researchPower = r.ReadDouble(); b.GetFloat64() // droneEjectEnergy = r.ReadDouble(); b.GetFloat64() // droneEnergyPerMeter = r.ReadDouble(); b.GetInt32le() // coreLevel = r.ReadInt32(); b.GetInt32le() // thrusterLevel = r.ReadInt32(); b.GetFloat32() // miningSpeed = r.ReadSingle(); b.GetFloat32() // replicateSpeed = r.ReadSingle(); b.GetFloat32() // walkSpeed = r.ReadSingle(); b.GetFloat32() // jumpSpeed = r.ReadSingle(); b.GetFloat32() // maxSailSpeed = r.ReadSingle(); b.GetFloat32() // maxWarpSpeed = r.ReadSingle(); b.GetFloat32() // buildArea = r.ReadSingle(); parseMechaForge(b) parseMechaLab(b) droneCount := b.GetInt32le() b.GetFloat32() // droneSpeed b.GetInt32le() // droneMovement for i := 0; int32(i) < droneCount; i++ { parseMechaDrone(b) } } func parseMechaDrone(b *Buffer) { checkVers(b, 0, "MechaDrone") b.GetInt32le() // stage = r.ReadInt32(); b.GetFloat32() // position.x = r.ReadSingle(); b.GetFloat32() // position.y = r.ReadSingle(); b.GetFloat32() // position.z = r.ReadSingle(); b.GetFloat32() // target.x = r.ReadSingle(); b.GetFloat32() // target.y = r.ReadSingle(); b.GetFloat32() // target.z = r.ReadSingle(); b.GetFloat32() // forward.x = r.ReadSingle(); b.GetFloat32() // forward.y = r.ReadSingle(); b.GetFloat32() // forward.z = r.ReadSingle(); b.GetFloat32() // speed = r.ReadSingle(); b.GetInt32le() // movement = r.ReadInt32(); b.GetInt32le() // targetObject = r.ReadInt32(); b.GetFloat32() // progress = r.ReadSingle(); b.GetFloat32() // initialVector.x = r.ReadSingle(); b.GetFloat32() // initialVector.y = r.ReadSingle(); b.GetFloat32() // initialVector.z = r.ReadSingle(); } func parseStorageComponent(b *Buffer) { checkVers(b, 1, "StorageComponent") b.GetInt32le() // id b.GetInt32le() // entityID b.GetInt32le() // previous b.GetInt32le() // next b.GetInt32le() // bottom b.GetInt32le() // top b.GetInt32le() // type = (EStorageType)r.ReadInt32(); size := b.GetInt32le() b.GetInt32le() // bans = r.ReadInt32(); for i := 0; int32(i) < size; i++ { b.GetInt32le() // grids[i].itemId = r.ReadInt32(); b.GetInt32le() // grids[i].filter = r.ReadInt32(); b.GetInt32le() // grids[i].count = r.ReadInt32(); b.GetInt32le() // grids[i].stackSize = r.ReadInt32(); } } func parsePlayerNavigation(b *Buffer) { checkVers(b, 0, "PlayerNavigation") b.GetBoolean() // navigating = r.ReadBoolean(); b.GetInt32le() // naviAstroId = r.ReadInt32(); b.GetFloat64() // naviTarget.x = r.ReadDouble(); b.GetFloat64() // naviTarget.y = r.ReadDouble(); b.GetFloat64() // naviTarget.z = r.ReadDouble(); b.GetBoolean() // useFly = r.ReadBoolean(); b.GetBoolean() // useSail = r.ReadBoolean(); b.GetBoolean() // useWarp = r.ReadBoolean(); b.GetInt32le() // stage = (ENaviStage)r.ReadInt32(); b.GetFloat64() // flyThreshold = r.ReadDouble(); b.GetFloat64() // sailThreshold = r.ReadDouble(); b.GetFloat64() // warpThreshold = r.ReadDouble(); b.GetFloat64() // maxSailSpeed = r.ReadDouble(); } func parseMechaForge(b *Buffer) { checkVers(b, 0, "MechaForge") count := b.GetInt32le() for i := 0; int32(i) < count; i++ { parseForgeTask(b) } } func parseForgeTask(b *Buffer) { checkVers(b, 0, "ForgeTask") b.GetInt32le() // recipeId = r.ReadInt32(); b.GetInt32le() // count = r.ReadInt32(); b.GetInt32le() // tick = r.ReadInt32(); b.GetInt32le() // tickSpend = r.ReadInt32(); itemIDCount := b.GetInt32le() productIDCount := b.GetInt32le() for i := 0; i < int(itemIDCount); i++ { b.GetInt32le() // itemIds[i] = r.ReadInt32(); b.GetInt32le() // itemCounts[i] = r.ReadInt32(); b.GetInt32le() // served[i] = r.ReadInt32(); } for i := 0; i < int(productIDCount); i++ { b.GetInt32le() // productIds[j] = r.ReadInt32(); b.GetInt32le() // productCounts[j] = r.ReadInt32(); b.GetInt32le() // produced[j] = r.ReadInt32(); } b.GetInt32le() // parentTaskIndex = r.ReadInt32(); } func parseMechaLab(b *Buffer) { checkVers(b, 0, "MechaLab") count := b.GetInt32le() for i := 0; int32(i) < count; i++ { b.GetInt32le() // key b.GetInt32le() // value } }
cmd/parsefile/parse_player.go
0.501465
0.412944
parse_player.go
starcoder
package support import ( "strings" "unicode" "github.com/fatih/camelcase" ) // IsCamelCase checks if a string is camelCase. func IsCamelCase(str string) bool { return !isFirstRuneDigit(str) && isMadeByAlphanumeric(str) && unicode.IsLower(runeAt(str, 0)) } // IsChainCase checks if a string is a chain-case. func IsChainCase(str string) bool { if strings.Contains(str, "-") { fields := strings.Split(str, "-") for _, field := range fields { if !isMadeByLowerAndDigit(field) { return false } } return true } return isMadeByLowerAndDigit(str) } // IsFlatCase checks if a string is a flatcase. func IsFlatCase(str string) bool { return !isFirstRuneDigit(str) && isMadeByLowerAndDigit(str) } // IsPascalCase checks if a string is a PascalCase. func IsPascalCase(str string) bool { if isFirstRuneDigit(str) { return false } return isAlphanumeric(str) && unicode.IsUpper(runeAt(str, 0)) } // IsSnakeCase checks if a string is a snake_case. func IsSnakeCase(str string) bool { if strings.Contains(str, "_") { fields := strings.Split(str, "_") for _, field := range fields { if !isMadeByLowerAndDigit(field) { return false } } return true } return isMadeByLowerAndDigit(str) } // ToCamelCase converts a string to camelCase style. func ToCamelCase(str string) string { if len(str) == 0 { return str } fields := splitToLowerFields(str) for i, f := range fields { if i != 0 { fields[i] = toUpperFirstRune(f) } } return strings.Join(fields, "") } // ToChainCase converts a string to chain-case style. func ToChainCase(str string) string { if len(str) == 0 { return str } fields := splitToLowerFields(str) return strings.Join(fields, "-") } // ToFlatCase converts a string to flatcase style. func ToFlatCase(str string) string { if len(str) == 0 { return str } fields := splitToLowerFields(str) return strings.Join(fields, "") } // ToPascalCase converts a string to PascalCase style. func ToPascalCase(str string) string { if len(str) == 0 { return str } fields := splitToLowerFields(str) for i, f := range fields { fields[i] = toUpperFirstRune(f) } return strings.Join(fields, "") } // ToSnakeCase converts a string to snake_case style. func ToSnakeCase(str string) string { if len(str) == 0 { return str } fields := splitToLowerFields(str) return strings.Join(fields, "_") } func isAlphanumeric(s string) bool { if len(s) == 0 { return false } for _, r := range s { if !unicode.IsUpper(r) && !unicode.IsLower(r) && !unicode.IsDigit(r) { return false } } return true } func isFirstRuneDigit(s string) bool { if len(s) == 0 { return false } return unicode.IsDigit(runeAt(s, 0)) } func isMadeByAlphanumeric(s string) bool { if len(s) == 0 { return false } for _, r := range s { if !unicode.IsUpper(r) && !unicode.IsLower(r) && !unicode.IsDigit(r) { return false } } return true } func isMadeByLowerAndDigit(s string) bool { if len(s) == 0 { return false } for _, r := range s { if !unicode.IsLower(r) && !unicode.IsDigit(r) { return false } } return true } func runeAt(s string, i int) rune { rs := []rune(s) return rs[0] } func splitToLowerFields(s string) []string { defaultCap := len([]rune(s)) / 3 fields := make([]string, 0, defaultCap) for _, sf := range strings.Fields(s) { for _, su := range strings.Split(sf, "_") { for _, sh := range strings.Split(su, "-") { for _, sc := range camelcase.Split(sh) { fields = append(fields, strings.ToLower(sc)) } } } } return fields } func toUpperFirstRune(s string) string { rs := []rune(s) return strings.ToUpper(string(rs[0])) + string(rs[1:]) }
support/string.go
0.66072
0.516778
string.go
starcoder
package genlsystem import ( "bufio" "fmt" "github.com/Flokey82/go_gens/vectors" "image/color" "math" "os" ) type Bounds3d struct { minX, minY, minZ float64 maxX, maxY, maxZ float64 } func (a *Bounds3d) AddPoint(x, y, z float64) { if a.minX > x { a.minX = x } if a.maxX < x { a.maxX = x } if a.minY > y { a.minY = y } if a.maxY < y { a.maxY = y } if a.minZ > z { a.minZ = z } if a.maxZ < z { a.maxZ = z } } func (a *Bounds3d) Size() (width, height, depth float64) { return a.maxX - a.minX, a.maxY - a.minY, a.maxZ - a.minZ } type stack3d struct { x, y, z float64 color color.Color width float64 forward vectors.Vec3 up vectors.Vec3 prev *stack3d } type line3d struct { x1, y1, x2, y2, z1, z2 float64 color color.Color width float64 } // Turtle3d implements a turtle-esque drawing system IN 3D! // This code is partially inspired by: // https://github.com/yalue/l_system_3d // and: // https://github.com/recp/cglm/blob/master/include/cglm/vec3.h type Turtle3d struct { rules map[string]func(*Turtle3d) cur *stack3d lines []line3d boundary *Bounds3d } // NewTurtle3d returns a new Turtle3d struct. func NewTurtle3d(rules map[string]func(*Turtle3d)) *Turtle3d { return &Turtle3d{ rules: rules, cur: &stack3d{ color: color.RGBA{0x00, 0x00, 0x00, 0xFF}, width: 1, forward: vectors.NewVec3(1, 0, 0), up: vectors.NewVec3(0, 1, 0), }, lines: []line3d{}, boundary: &Bounds3d{}, } } // save position and angle func (t *Turtle3d) Save() { t.cur = &stack3d{ x: t.cur.x, y: t.cur.y, z: t.cur.z, color: t.cur.color, width: t.cur.width, prev: t.cur, // stackception up: t.cur.up, forward: t.cur.forward, } } // restore position and angle func (t *Turtle3d) Restore() { if t.cur == nil { return } if p := t.cur.prev; p != nil { t.cur.prev = nil // stackalypse t.cur = p } } // Move moves forward without drawing. func (t *Turtle3d) Move(f float64) { x, y, z := t.advanceRotateEtc(f) t.cur.x += x t.cur.y += y t.cur.z += z t.boundary.AddPoint(t.cur.x, t.cur.y, t.cur.z) } func (t *Turtle3d) advanceRotateEtc(distance float64) (x, y, z float64) { change := t.cur.forward.Mul(distance) x = change.X y = change.Y z = change.Z return } // Draw draws a line forward. func (t *Turtle3d) Draw(f float64) { sx, sy, sz := t.cur.x, t.cur.y, t.cur.z x, y, z := t.advanceRotateEtc(f) t.cur.x += x t.cur.y += y t.cur.z += z t.boundary.AddPoint(t.cur.x, t.cur.y, t.cur.z) t.lines = append(t.lines, line3d{ x1: sx, y1: sy, z1: sz, x2: t.cur.x, y2: t.cur.y, z2: t.cur.z, color: t.cur.color, width: t.cur.width, }) } // GetPosition gets the current position. func (t *Turtle3d) GetPosition() (x, y, z float64) { return t.cur.x, t.cur.y, t.cur.z } func degToRadians(degrees float64) float64 { return degrees * (math.Pi / 180.0) } // Rotate is the same as Yaw. func (t *Turtle3d) Rotate(angle float64) { glm_vec3_rotate(&t.cur.forward, degToRadians(angle), t.cur.up) } func (t *Turtle3d) Pitch(angle float64) { right := vectors.Cross3(t.cur.forward, t.cur.up) glm_vec3_rotate(&t.cur.up, degToRadians(angle), right) glm_vec3_rotate(&t.cur.forward, degToRadians(angle), right) } func (t *Turtle3d) Roll(angle float64) { glm_vec3_rotate(&t.cur.up, degToRadians(angle), t.cur.forward) } // GetForward gets the current forward vector func (t *Turtle3d) GetForward() vectors.Vec3 { return t.cur.forward } // SetColor sets the current color. func (t *Turtle3d) SetColor(c color.Color) { t.cur.color = c } // GetColor gets the current color. func (t *Turtle3d) GetColor() color.Color { return t.cur.color } // SetWidth sets the current width. func (t *Turtle3d) SetWidth(w float64) { t.cur.width = w } // GetWidth gets the current width. func (t *Turtle3d) GetWidth() float64 { return t.cur.width } // UNLEASH THE TURTLE! func (t *Turtle3d) Go(fname string, path []string) error { // draw lines for _, c := range path { if f, ok := t.rules[c]; ok { f(t) } } border := 5.0 offx, offy, offz := t.boundary.minX-border, t.boundary.minY-border, t.boundary.minZ-border // Generate index for vertex indices. var vxs [][3]float64 vtxIdx := make(map[[3]float64]int) for _, line := range t.lines { start := [3]float64{line.x1 - offx, line.y1 - offy, line.z1 - offz} if _, ok := vtxIdx[start]; !ok { vtxIdx[start] = len(vxs) vxs = append(vxs, start) } stop := [3]float64{line.x2 - offx, line.y2 - offy, line.z2 - offz} if _, ok := vtxIdx[stop]; !ok { vtxIdx[stop] = len(vxs) vxs = append(vxs, stop) } } f, err := os.Create(fname) if err != nil { return err } defer f.Close() wr := bufio.NewWriter(f) for _, p := range vxs { wr.WriteString(fmt.Sprintf("v %f %f %f \n", p[0], p[1], p[2])) } for _, line := range t.lines { start := [3]float64{line.x1 - offx, line.y1 - offy, line.z1 - offz} stop := [3]float64{line.x2 - offx, line.y2 - offy, line.z2 - offz} wr.WriteString(fmt.Sprintf("l %d %d \n", vtxIdx[start]+1, vtxIdx[stop]+1)) } wr.Flush() // cleanup t.Cleanup() return nil } func (t *Turtle3d) Cleanup() { t.cur = &stack3d{ color: color.RGBA{0x00, 0x00, 0x00, 0xFF}, width: 1, forward: vectors.NewVec3(1, 0, 0), up: vectors.NewVec3(0, 1, 0), } t.lines = nil t.boundary = new(Bounds3d) } func glm_vec3_rotate(v *vectors.Vec3, angle float64, axis vectors.Vec3) { c := math.Cos(angle) s := math.Sin(angle) k := axis.Normalize() /* Right Hand, Rodrigues' rotation formula: v = v*cos(t) + (kxv)sin(t) + k*(k.v)(1 - cos(t)) */ v1 := v.Mul(c) v2 := vectors.Cross3(k, *v) v2 = v2.Mul(s) v1 = vectors.Add3(v1, v2) v2 = k.Mul(vectors.Dot3(k, *v) * (1.0 - c)) *v = vectors.Add3(v1, v2) }
genlsystem/turtlegraph3d.go
0.795301
0.42477
turtlegraph3d.go
starcoder
package g // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // HTML Audio / Video Methods - http://www.w3schools.com/tags/ref_av_dom.asp // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- func (ele *ELEMENT) AddTextTrack(eval string) *ELEMENT { return ele.Attr("addTextTrack()", eval) } func (ele *ELEMENT) CanPlayType(eval string) *ELEMENT { return ele.Attr("canPlayType()", eval) } func (ele *ELEMENT) Load(eval string) *ELEMENT { return ele.Attr("load()", eval) } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // HTML Audio / Video Propertios - http://www.w3schools.com/tags/ref_av_dom.asp // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- func (ele *ELEMENT) AudioTracks(eval string) *ELEMENT { return ele.Attr("audioTracks", eval) } func (ele *ELEMENT) Autoplay(eval string) *ELEMENT { return ele.Attr("autoplay", eval) } func (ele *ELEMENT) Buffered(eval string) *ELEMENT { return ele.Attr("buffered", eval) } func (ele *ELEMENT) Controller(eval string) *ELEMENT { return ele.Attr("controller", eval) } func (ele *ELEMENT) Controls(eval string) *ELEMENT { return ele.Attr("controls", eval) } func (ele *ELEMENT) CrossOrigin(eval string) *ELEMENT { return ele.Attr("crossOrigin", eval) } func (ele *ELEMENT) CurrentSrc(eval string) *ELEMENT { return ele.Attr("currentSrc", eval) } func (ele *ELEMENT) CurrentTime(eval string) *ELEMENT { return ele.Attr("currentTime", eval) } func (ele *ELEMENT) DefaultMuted(eval string) *ELEMENT { return ele.Attr("defaultMuted", eval) } func (ele *ELEMENT) DefaultPlaybackRate(eval string) *ELEMENT { return ele.Attr("defaultPlaybackRate", eval) } func (ele *ELEMENT) Duration(eval string) *ELEMENT { return ele.Attr("duration", eval) } func (ele *ELEMENT) Loop(eval string) *ELEMENT { return ele.Attr("loop", eval) } func (ele *ELEMENT) MediaGroup(eval string) *ELEMENT { return ele.Attr("mediaGroup", eval) } func (ele *ELEMENT) Muted(eval string) *ELEMENT { return ele.Attr("muted", eval) } func (ele *ELEMENT) NetworkState(eval string) *ELEMENT { return ele.Attr("networkState", eval) } func (ele *ELEMENT) Paused(eval string) *ELEMENT { return ele.Attr("paused", eval) } func (ele *ELEMENT) PlaybackRate(eval string) *ELEMENT { return ele.Attr("playbackRate", eval) } func (ele *ELEMENT) Played(eval string) *ELEMENT { return ele.Attr("played", eval) } func (ele *ELEMENT) Preload(eval string) *ELEMENT { return ele.Attr("preload", eval) } func (ele *ELEMENT) ReadyState(eval string) *ELEMENT { return ele.Attr("readyState", eval) } func (ele *ELEMENT) Seekable(eval string) *ELEMENT { return ele.Attr("seekable", eval) } // Moved to html_sharedAttributes.go because of conflict // func (ele *ELEMENT) Src(eval string) *ELEMENT { return ele.Attr("src", eval) } func (ele *ELEMENT) StartDate(eval string) *ELEMENT { return ele.Attr("startDate", eval) } func (ele *ELEMENT) TextTracks(eval string) *ELEMENT { return ele.Attr("textTracks", eval) } func (ele *ELEMENT) VideoTracks(eval string) *ELEMENT { return ele.Attr("videoTracks", eval) } func (ele *ELEMENT) Volume(eval string) *ELEMENT { return ele.Attr("volume", eval) } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // HTML Audio / Video Events - http://www.w3schools.com/tags/ref_av_dom.asp // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- func (ele *ELEMENT) Abort(eval string) *ELEMENT { return ele.Attr("abort", eval) } func (ele *ELEMENT) Canplay(eval string) *ELEMENT { return ele.Attr("canplay", eval) } func (ele *ELEMENT) Canplaythrough(eval string) *ELEMENT { return ele.Attr("canplaythrough", eval) } func (ele *ELEMENT) Durationchange(eval string) *ELEMENT { return ele.Attr("durationchange", eval) } func (ele *ELEMENT) Emptied(eval string) *ELEMENT { return ele.Attr("emptied", eval) } func (ele *ELEMENT) Loadeddata(eval string) *ELEMENT { return ele.Attr("loadeddata", eval) } func (ele *ELEMENT) Loadedmetadata(eval string) *ELEMENT { return ele.Attr("loadedmetadata", eval) } func (ele *ELEMENT) Loadstart(eval string) *ELEMENT { return ele.Attr("loadstart", eval) } func (ele *ELEMENT) Playing(eval string) *ELEMENT { return ele.Attr("playing", eval) } func (ele *ELEMENT) Progress(eval string) *ELEMENT { return ele.Attr("progress", eval) } func (ele *ELEMENT) Ratechange(eval string) *ELEMENT { return ele.Attr("ratechange", eval) } func (ele *ELEMENT) Seeked(eval string) *ELEMENT { return ele.Attr("seeked", eval) } func (ele *ELEMENT) Stalled(eval string) *ELEMENT { return ele.Attr("stalled", eval) } func (ele *ELEMENT) Suspend(eval string) *ELEMENT { return ele.Attr("suspend", eval) } func (ele *ELEMENT) Timeupdate(eval string) *ELEMENT { return ele.Attr("timeupdate", eval) } func (ele *ELEMENT) Volumechange(eval string) *ELEMENT { return ele.Attr("volumechange", eval) } func (ele *ELEMENT) Waiting(eval string) *ELEMENT { return ele.Attr("waiting", eval) } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // HTML Audio / Video Shared Attributes - http://www.w3schools.com/tags/ref_av_dom.asp // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- func (ele *ELEMENT) Ended(eval string) *ELEMENT { return ele.Attr("ended", eval) } func (ele *ELEMENT) Error(eval string) *ELEMENT { return ele.Attr("error", eval) } func (ele *ELEMENT) Pause(eval string) *ELEMENT { return ele.Attr("pause", eval) } func (ele *ELEMENT) Play(eval string) *ELEMENT { return ele.Attr("play", eval) } func (ele *ELEMENT) Seeking(eval string) *ELEMENT { return ele.Attr("seeking", eval) }
markup/html_av.go
0.563378
0.42179
html_av.go
starcoder
package graph // PageRank implements type PageRank struct { DirectedNetwork [][]bool H [][]float64 G [][]float64 Rank map[int64]float64 Directed map[int64]bool NodeNum int64 } // NewPageRank return pagerank func NewPageRank(nodeNum int64, edges [][2]int64) *PageRank { pagerank := new(PageRank) pagerank.NodeNum = nodeNum pagerank.DirectedNetwork = make([][]bool, nodeNum) pagerank.H = make([][]float64, nodeNum) pagerank.G = make([][]float64, nodeNum) pagerank.Directed = make(map[int64]bool) pagerank.Rank = make(map[int64]float64) for node := range pagerank.DirectedNetwork { pagerank.DirectedNetwork[node] = make([]bool, nodeNum) pagerank.H[node] = make([]float64, nodeNum) pagerank.G[node] = make([]float64, nodeNum) } for i := 0; int64(i) < nodeNum; i++ { pagerank.Directed[int64(i)] = false } for edge := range edges { pagerank.DirectedNetwork[edges[edge][0]-1][edges[edge][1]-1] = true pagerank.Directed[edges[edge][1]-1] = true } return pagerank } // HyperLinkMatrix calclate HyperLinkMatrix based on DirectedNetwork, return HyperLinkMatrix func (o *PageRank) HyperLinkMatrix() [][]float64 { for from := range o.DirectedNetwork { refNum := 0 var directeds []int64 for to := range o.DirectedNetwork[from] { if o.DirectedNetwork[from][to] { refNum++ directeds = append(directeds, int64(to)) } } for node := range directeds { o.H[from][directeds[node]] = 1.0 / float64(refNum) } } return o.H } // GoogleMatrix calclate GoogleMatrix based on random surfer, etc.. func (o *PageRank) GoogleMatrix(randomsurfer float64) [][]float64 { if randomsurfer < 0.0 || randomsurfer > 1.0 { return nil } S := o.calcS() for row := range S { for col := range S[row] { o.G[row][col] = randomsurfer*S[row][col] + (1.0-randomsurfer)/float64(o.NodeNum) } } return o.G } func (o *PageRank) calcS() [][]float64 { a := make([]float64, o.NodeNum) e := make([]float64, o.NodeNum) for i := 0; int64(i) < o.NodeNum; i++ { a[i] = 1.0 if o.Directed[int64(i)] { a[i] = 0.0 } } e[0] = 1 for i := 1; int64(i) < o.NodeNum; i *= 2 { copy(e[i:], e[:i]) } coefficient := outer(a, e) return add(o.H, coefficient) } func outer(m, n []float64) [][]float64 { mlen := len(m) nlen := len(n) res := make([][]float64, nlen) for i := range res { res[i] = make([]float64, mlen) } for col := range m { for row := range n { res[row][col] = m[col] * n[row] } } return res } func add(m, n [][]float64) [][]float64 { res := make([][]float64, len(m)) for row := range m { res[row] = make([]float64, len(m[row])) for col := range m[row] { res[row][col] = m[row][col] + n[row][col] } } return res } func multi(m, n [][]float64) [][]float64 { lencol := len(m[0]) lenrow := len(n) if lencol != lenrow { return nil } res := make([][]float64, len(m)) for i := 0; i < len(m); i++ { res[i] = make([]float64, len(n[0])) for j := 0; j < len(n[0]); j++ { var val float64 for k := 0; k < lenrow; k++ { val += m[i][k] * n[k][j] } res[i][j] = val } } return res } // CalcPageRank calclate each nodes pagerank func (o *PageRank) CalcPageRank(randomsurfer float64, repetition int) map[int64]float64 { o.HyperLinkMatrix() o.GoogleMatrix(0.5) pie := make([]float64, o.NodeNum) pie[0] = 1 / float64(o.NodeNum) for i := 1; int64(i) < o.NodeNum; i *= 2 { copy(pie[i:], pie[:i]) } base := make([][]float64, 1) base[0] = pie for i := 0; i < repetition; i++ { base = multi(base, o.G) } for node := range base[0] { o.Rank[int64(node)] = base[0][node] } return o.Rank }
graph/pagerank.go
0.566019
0.439928
pagerank.go
starcoder
package mpc import ( "crypto/rand" "fmt" "math/big" mr "math/rand" ) var one = new(big.Int).SetInt64(1) // GenerateShares generates `n` shares such that (`s_1` + ... + `s_n`) mod `M` = `secret` func GenerateShares(secret int64, n int, M *big.Int) []*big.Int { s := new(big.Int).SetInt64(secret) sum := new(big.Int) shares := make([]*big.Int, n) j := mr.Intn(n) for i := 0; i < n; i++ { if i != j { shares[i] = getRandom(M) sum.Add(sum, shares[i]) } } shares[j] = s.Sub(s, sum).Mod(s, M) return shares } // GenerateBeaverTriplet generate three numbers `w` = `uv` mod `N` func GenerateBeaverTriplet(N *big.Int) [3]*big.Int { var triplet [3]*big.Int x, y := getRandom(N), getRandom(N) if mr.Intn(2) > 0 { // u = x, v = y, w = xy mod N w := new(big.Int).Mul(x, y) triplet[0] = w.Mod(w, N) triplet[1] = x triplet[2] = y } else { // v = x, w = y, u = (xy^-1)^-1 mod N u := new(big.Int).Mul(x, new(big.Int).ModInverse(y, N)) triplet[0] = y triplet[1] = x triplet[2] = u.ModInverse(u, N) } return triplet } // Message format exchanged between protocol parties type Message struct { id int // party id in the protocol round/instance v []*big.Int // intermediate values } // BroadcastAgent used as single message exchange channel type BroadcastAgent struct { parties map[int]chan<- []Message messages []Message } // NewBroadcastAgent returns the pointer to a new BroadcastAgent instance func NewBroadcastAgent(n int) *BroadcastAgent { return &BroadcastAgent{} } // Broadcast a message to all prototol parties func (ba *BroadcastAgent) Broadcast(round int, m Message) { ba.messages = append(ba.messages, m) if len(ba.messages) == len(ba.parties) { for _, ch := range ba.parties { ch <- ba.messages } } } // Subscribe to the BA in order to receive protocol messages func (ba *BroadcastAgent) Subscribe(id int, ch chan chan<- []Message) { c, ok := <-ch if ok { ba.parties[id] = c } } // Parameters needed to run the secret sharing protocols on the commodity model type Parameters struct { n int // number of computing parties M *big.Int // modulus for circular group operations triplet [3]*big.Int // beaver's triplep, for multiplication optmization (this is the commodity model) assinc int // assincronous bit, to mark the protocol party with different multiplication setup on the commodity model } // NewParameters creates default protocol parameters for testing func NewParameters(bitlen int) *Parameters { m, err := rand.Prime(rand.Reader, bitlen) if err != nil { panic("Could not generate randon prime") } n := 3 return &Parameters{ n: n, M: m, triplet: GenerateBeaverTriplet(m), assinc: mr.Intn(n), } } // IntProtocol represents the default structure for secret-sharing protocol // to perform computations of integers type IntProtocol interface { Setup(param *Parameters, args []int64) error Run() error Output() int64 } // Party models a protocol party type Party interface { //Instanciate(id int, param *Parameters, ba *BroadcastAgent) error Run() } // getRandom generates a random Int `r` such that `r < N` and `gcd(r, N) = 1` func getRandom(N *big.Int) *big.Int { gcd := new(big.Int) r := new(big.Int) err := fmt.Errorf("") for gcd.Cmp(one) != 0 { r, err = rand.Int(rand.Reader, N) if err != nil { panic("Error while reading crypto/rand") } gcd = new(big.Int).GCD(nil, nil, r, N) } return r }
secret_sharing.go
0.70304
0.416737
secret_sharing.go
starcoder
package testgomavlib import ( "bytes" "errors" "math" "reflect" "regexp" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/team-rocos/gomavlib" libgen "github.com/team-rocos/gomavlib/commands/dialgen/libgen" "github.com/xeipuuv/gojsonschema" ) // DEFINE PUBLIC TYPES AND STRUCTURES. // DEFINE PRIVATE TYPES AND STRUCTURES. // DEFINE PUBLIC STATIC FUNCTIONS. // CreateMessageByIdTest creates a dynamic message based on the input id and checks that the values within it are valid. func CreateMessageByIdTest(t *testing.T, xmlPath string, includeDirs []string) { defs, version, err := libgen.XMLToFields(xmlPath, includeDirs) require.NoError(t, err) // Create dialect from the parsed defs. dRT, err := gomavlib.NewDialectRT(version, defs) require.NoError(t, err) // Create dynamic message using id of each message in dRT for _, mRT := range dRT.Messages { dm, err := dRT.CreateMessageById(uint32(mRT.Msg.Id)) require.NoError(t, err) require.Equal(t, mRT, dm.T) } // CreateMessageById using invalid id. Assert that error is returned _, err = dRT.CreateMessageById(40000000) assert.Error(t, err) } // CreateMessageByNameTest creates a dynamic message based on the input name and checks that the values within it are valid. func CreateMessageByNameTest(t *testing.T, xmlPath string, includeDirs []string) { defs, version, err := libgen.XMLToFields(xmlPath, includeDirs) require.NoError(t, err) // Create dialect from the parsed defs. dRT, err := gomavlib.NewDialectRT(version, defs) require.NoError(t, err) // Create dynamic message by name using name from each mRT in dRT for _, mRT := range dRT.Messages { dm, err := dRT.CreateMessageByName(mRT.Msg.OriginalName) require.NoError(t, err) require.Equal(t, mRT, dm.T) } // Create dynamic message using invalid name. Assert that error is returned _, err = dRT.CreateMessageByName("abcdefghijklmnop***") assert.Error(t, err) } // JSONMarshalAndUnmarshalTest tests JSON generation, schema generation, and JSON unmarshal code. func JSONMarshalAndUnmarshalTest(t *testing.T, xmlPath string, includeDirs []string) { for i, c := range casesMsgsTest { dCT, err := gomavlib.NewDialectCT(3, ctMessages) require.NoError(t, err) dMsgCT, ok := dCT.Messages[c.id] require.Equal(t, true, ok) bytesEncoded, err := dMsgCT.Encode(c.parsed, c.isV2) require.NoError(t, err) require.Equal(t, c.raw, bytesEncoded) // Decode bytes using RT defs, version, err := libgen.XMLToFields(xmlPath, includeDirs) require.NoError(t, err) // Create dialect from the parsed defs. dRT, err := gomavlib.NewDialectRT(version, defs) require.NoError(t, err) dMsgRT := dRT.Messages[c.id] require.Equal(t, uint(3), dRT.GetVersion()) // Decode bytes using RT msgDecoded, err := dMsgRT.Decode(c.raw, c.isV2) require.NoError(t, err) // Marshal JSON bytesCreated, err := msgDecoded.(*gomavlib.DynamicMessage).MarshalJSON() require.NoError(t, err) if i == 7 || i == 8 { // Test cases with altered JSON require.NotEqual(t, jsonTest[i], string(bytesCreated)) } else { require.Equal(t, jsonTest[i], string(bytesCreated)) } // Generate JSON Schema schemaBytes, err := msgDecoded.(*gomavlib.DynamicMessage).GenerateJSONSchema("/mavlink", "topic") require.NoError(t, err) if i == 7 { // Test case with altered schema example require.NotEqual(t, schemasTest[i], string(schemaBytes)) } else { require.Equal(t, schemasTest[i], string(schemaBytes)) } // Validate JSON document against schema schemaLoader := gojsonschema.NewStringLoader(schemasTest[i]) documentLoader := gojsonschema.NewStringLoader(jsonTest[i]) result, err := gojsonschema.Validate(schemaLoader, documentLoader) if i == 8 { // JSONTest[8] has a string entry where it should be float32 - should not validate against schemasTest[8] require.NoError(t, err) require.Equal(t, false, result.Valid()) } else if i == 1 || i == 9 { // float as nan, +inf, or -inf string not accepted require.NoError(t, err) require.Equal(t, false, result.Valid()) } else { require.NoError(t, err) require.Equal(t, true, result.Valid()) } // Test Unmarshal // Create new DynamicMessage with empty fields for testing unmarshal dm, err := dRT.CreateMessageById(uint32(dRT.Messages[c.id].Msg.Id)) require.NoError(t, err) err = dm.UnmarshalJSON(bytesCreated) require.NoError(t, err) if i == 1 { // Check that NaN, Inf, and -Inf have been umarshalled correctly. check := math.IsNaN(float64(dm.Fields["flow_comp_m_x"].(gomavlib.JsonFloat32).F)) require.Equal(t, true, check) check = math.IsInf(float64(dm.Fields["flow_comp_m_y"].(gomavlib.JsonFloat32).F), 1) require.Equal(t, true, check) check = math.IsInf(float64(dm.Fields["ground_distance"].(gomavlib.JsonFloat32).F), -1) require.Equal(t, true, check) // check that SetField as a float32 also works: err := dm.SetField("flow_comp_m_x", float32(math.NaN())) require.NoError(t, err) check = math.IsNaN(float64(dm.Fields["flow_comp_m_x"].(gomavlib.JsonFloat32).F)) require.Equal(t, true, check) } else if i == 9 { // Check slice of NaN, +Inf, and -Inf float 64 values. array := dm.Fields["distance"].([]gomavlib.JsonFloat64) patternCount := 0 for j := 0; j < 16; j++ { val := array[j].F if patternCount <= 1 { check := math.IsNaN(val) require.Equal(t, true, check) patternCount++ } else if patternCount == 2 { check := math.IsInf(val, 1) require.Equal(t, true, check) patternCount++ } else if patternCount == 3 { check := math.IsInf(val, -1) require.Equal(t, true, check) patternCount = 0 // Reset the pattern } } // Check that SetField as a slice of float64 also works floatSlice := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} err := dm.SetField("distance", floatSlice) require.NoError(t, err) vals, ok := dm.Fields["distance"].([]gomavlib.JsonFloat64) require.Equal(t, true, ok) for i, val := range vals { require.Equal(t, float64(i+1), val.F) } } else { require.Equal(t, msgDecoded.(*gomavlib.DynamicMessage).Fields, dm.Fields) } } } // DialectRTCommonXMLTest tests the XMLToFields and RT dialect generation functionality added to gomavlib. func DialectRTCommonXMLTest(t *testing.T, xmlPath string, includeDirs []string) { // Ensure that XMLToFields works with no include files, if xml file has no includes _, _, err := libgen.XMLToFields(xmlPath, make([]string, 0)) require.NoError(t, err) // Parse the XML file. defs, version, err := libgen.XMLToFields(xmlPath, includeDirs) require.NoError(t, err) // Create dialect from the parsed defs. dRT, err := gomavlib.NewDialectRT(version, defs) require.NoError(t, err) require.Equal(t, uint(3), dRT.GetVersion()) // Check Individual Messages for RT msg := dRT.Messages[5].Msg require.Equal(t, "ChangeOperatorControl", msg.Name) require.Equal(t, 5, msg.Id) field := msg.Fields[0] require.Equal(t, "TargetSystem", field.Name) require.Equal(t, "uint8", field.Type) field = msg.Fields[3] require.Equal(t, "Passkey", field.Name) require.Equal(t, "string", field.Type) // Checking Message 82 - Has float[4] array as a field msg = dRT.Messages[82].Msg require.Equal(t, "SetAttitudeTarget", msg.Name) require.Equal(t, 82, msg.Id) field = msg.Fields[1] require.Equal(t, "Q", field.Name) require.Equal(t, "float32", field.Type) // Compare with DialectCT dCT, err := gomavlib.NewDialectCT(3, ctMessages) require.NoError(t, err) require.Equal(t, len(dCT.Messages), len(dRT.Messages)) // Compare RT and CT for all messages for _, m := range ctMessages { index := m.GetId() // Compare dCT with dRT mCT := dCT.Messages[index] mRT := dRT.Messages[index] require.Equal(t, mCT.GetSizeNormal(), byte(mRT.GetSizeNormal())) require.Equal(t, mCT.GetSizeExtended(), byte(mRT.GetSizeExtended())) require.Equal(t, mCT.GetCRCExtra(), mRT.GetCRCExtra()) // Compare all fields of all RT and CT Messages for i := 0; i < len(mCT.Fields); i++ { fCT := mCT.Fields[i] fRT := mRT.Msg.Fields[i] require.Equal(t, fCT.GetIsEnum(), fRT.IsEnum) require.Equal(t, fCT.GetFType(), gomavlib.DialectFieldTypeFromGo[fRT.Type]) require.Equal(t, fCT.GetName(), fRT.OriginalName) require.Equal(t, fCT.GetArrayLength(), byte(fRT.ArrayLength)) require.Equal(t, fCT.GetIndex(), fRT.Index) require.Equal(t, fCT.GetIsExtension(), fRT.IsExtension) } } } // DecodeAndEncodeRTTest tests run time (RT) encoding and decoding of messages func DecodeAndEncodeRTTest(t *testing.T, xmlPath string, includeDirs []string) { for index, c := range casesMsgsTest { // Encode using CT dCT, err := gomavlib.NewDialectCT(3, ctMessages) require.NoError(t, err) dMsgCT, ok := dCT.Messages[c.id] require.Equal(t, true, ok) bytesEncoded, err := dMsgCT.Encode(c.parsed, c.isV2) require.NoError(t, err) require.Equal(t, c.raw, bytesEncoded) // Decode bytes using CT method for RT vs CT comparison later msgDecodedCT, err := dMsgCT.Decode(c.raw, c.isV2) require.NoError(t, err) if index != 1 && index != 9 { // require.Equal will not work for two equal messages with a field of NaN, since two NaN values are defined as not equal. require.Equal(t, c.parsed, msgDecodedCT) } // Decode bytes using RT defs, version, err := libgen.XMLToFields(xmlPath, includeDirs) require.NoError(t, err) // Create dialect from the parsed defs. dRT, err := gomavlib.NewDialectRT(version, defs) dMsgRT := dRT.Messages[c.id] require.NoError(t, err) require.Equal(t, uint(3), dRT.GetVersion()) // Decode bytes using RT msgDecoded, err := dMsgRT.Decode(bytesEncoded, c.isV2) require.NoError(t, err) //Make sure all fields of dMsgCT match equivalent values of RT msgDecoded //Compare all fields of all RT and CT Messages v := reflect.ValueOf(msgDecodedCT).Elem() for j := 0; j < len(dMsgCT.Fields); j++ { fCT := dMsgCT.Fields[j] originalName := fCT.GetName() name := dialectMsgDefToGo(originalName) fRT := msgDecoded.(*gomavlib.DynamicMessage).Fields[originalName] fCTVal := v.FieldByName(name) fieldType, arrayLength, err := findFieldType(msgDecoded.(*gomavlib.DynamicMessage), originalName) require.NoError(t, err) switch fieldType { case "int8": if arrayLength != 0 { rtResult := fRT.([]int8) ctResult := make([]int8, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int8 { ctResult[i] = int8(fCTVal.Index(i).Int()) } else { ctResult[i] = int8(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int8 { require.Equal(t, int8(fCTVal.Int()), fRT.(int8)) } else { require.Equal(t, int8(fCTVal.Uint()), fRT.(int8)) } } case "uint8": if arrayLength != 0 { rtResult := fRT.([]uint8) ctResult := make([]uint8, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int8 { ctResult[i] = uint8(fCTVal.Index(i).Int()) } else { ctResult[i] = uint8(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int8 { require.Equal(t, uint8(fCTVal.Int()), fRT.(uint8)) } else { require.Equal(t, uint8(fCTVal.Uint()), fRT.(uint8)) } } case "int16": if arrayLength != 0 { rtResult := fRT.([]int16) ctResult := make([]int16, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int16 { ctResult[i] = int16(fCTVal.Index(i).Int()) } else { ctResult[i] = int16(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int16 { require.Equal(t, int16(fCTVal.Int()), fRT.(int16)) } else { require.Equal(t, int16(fCTVal.Uint()), fRT.(int16)) } } case "uint16": if arrayLength != 0 { rtResult := fRT.([]uint16) ctResult := make([]uint16, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int16 { ctResult[i] = uint16(fCTVal.Index(i).Int()) } else { ctResult[i] = uint16(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int16 { require.Equal(t, uint16(fCTVal.Int()), fRT.(uint16)) } else { require.Equal(t, uint16(fCTVal.Uint()), fRT.(uint16)) } } case "int32": if arrayLength != 0 { rtResult := fRT.([]int32) ctResult := make([]int32, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int32 { ctResult[i] = int32(fCTVal.Index(i).Int()) } else { ctResult[i] = int32(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int32 { require.Equal(t, int32(fCTVal.Int()), fRT.(int32)) } else { require.Equal(t, int32(fCTVal.Uint()), fRT.(int32)) } } case "uint32": if arrayLength != 0 { rtResult := fRT.([]uint32) ctResult := make([]uint32, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int32 { ctResult[i] = uint32(fCTVal.Index(i).Int()) } else { ctResult[i] = uint32(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int32 { require.Equal(t, uint32(fCTVal.Int()), fRT.(uint32)) } else { require.Equal(t, uint32(fCTVal.Uint()), fRT.(uint32)) } } case "int64": if arrayLength != 0 { rtResult := fRT.([]int64) ctResult := make([]int64, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int64 { ctResult[i] = int64(fCTVal.Index(i).Int()) } else { ctResult[i] = int64(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int64 { require.Equal(t, int64(fCTVal.Int()), fRT.(int64)) } else { require.Equal(t, int64(fCTVal.Uint()), fRT.(int64)) } } case "uint64": if arrayLength != 0 { rtResult := fRT.([]uint64) ctResult := make([]uint64, arrayLength) for i := 0; i < arrayLength; i++ { if fCTVal.Index(i).Kind() == reflect.Int || fCTVal.Index(i).Kind() == reflect.Int64 { ctResult[i] = uint64(fCTVal.Index(i).Int()) } else { ctResult[i] = uint64(fCTVal.Index(i).Uint()) } } require.Equal(t, ctResult, rtResult) } else { if fCTVal.Kind() == reflect.Int || fCTVal.Kind() == reflect.Int64 { require.Equal(t, uint64(fCTVal.Int()), fRT.(uint64)) } else { require.Equal(t, uint64(fCTVal.Uint()), fRT.(uint64)) } } case "float64": if arrayLength != 0 { temp := fRT.([]gomavlib.JsonFloat64) rtResult := make([]float64, arrayLength) ctResult := make([]float64, arrayLength) for i := 0; i < arrayLength; i++ { ctResult[i] = float64(fCTVal.Index(i).Float()) rtResult[i] = temp[i].F } if index == 9 { for i := 0; i < arrayLength; i++ { if math.IsNaN(ctResult[i]) { check := math.IsNaN(rtResult[i]) require.Equal(t, true, check) } else if math.IsInf(ctResult[i], 1) { check := math.IsInf(rtResult[i], 1) require.Equal(t, true, check) } else if math.IsInf(ctResult[i], -1) { check := math.IsInf(rtResult[i], -1) require.Equal(t, true, check) } } } else { require.Equal(t, ctResult, rtResult) } } else { require.Equal(t, float64(fCTVal.Float()), fRT.(gomavlib.JsonFloat64).F) } case "float32": if arrayLength != 0 { temp := fRT.([]gomavlib.JsonFloat32) rtResult := make([]float32, arrayLength) ctResult := make([]float32, arrayLength) for i := 0; i < arrayLength; i++ { ctResult[i] = float32(fCTVal.Index(i).Float()) rtResult[i] = temp[i].F } require.Equal(t, ctResult, rtResult) } else { if index == 1 { // Use CT Val to check for NaN, +Inf, and -Inf. Use this to test RT results. nan := math.IsNaN(fCTVal.Float()) posInf := math.IsInf(fCTVal.Float(), 1) negInf := math.IsInf(fCTVal.Float(), -1) if nan { test := math.IsNaN(float64(fRT.(gomavlib.JsonFloat32).F)) require.Equal(t, true, test) } else if posInf { test := math.IsInf(float64(fRT.(gomavlib.JsonFloat32).F), 1) require.Equal(t, true, test) } else if negInf { test := math.IsInf(float64(fRT.(gomavlib.JsonFloat32).F), -1) require.Equal(t, true, test) } else { // Else treat normally require.Equal(t, float32(fCTVal.Float()), fRT.(gomavlib.JsonFloat32).F) } } else { // Else treat normally require.Equal(t, float32(fCTVal.Float()), fRT.(gomavlib.JsonFloat32).F) } } case "string": require.Equal(t, fCTVal.String(), fRT.(string)) default: err = errors.New("invalid type so unable to convert interface values") panic(err) } } // Encode using RT bytesEncodedByRT, err := dMsgRT.Encode(msgDecoded, c.isV2) require.NoError(t, err) require.Equal(t, c.raw, bytesEncodedByRT) } } func findFieldType(dm *gomavlib.DynamicMessage, originalName string) (string, int, error) { for _, f := range dm.T.Msg.Fields { if f.OriginalName == originalName { return f.Type, f.ArrayLength, nil } } err := errors.New("field with given OriginalName does not exist") return "", 0, err } var schemasTest = []string{ "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"acc_x\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"acc_y\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"acc_z\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"command\":{\"items\":{\"type\":\"integer\"},\"type\":\"array\"},\"pos_x\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"pos_y\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"pos_yaw\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"pos_z\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"time_usec\":{\"type\":\"integer\"},\"valid_points\":{\"type\":\"integer\"},\"vel_x\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"vel_y\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"vel_yaw\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"vel_z\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"flow_comp_m_x\":{\"type\":\"number\"},\"flow_comp_m_y\":{\"type\":\"number\"},\"flow_rate_x\":{\"type\":\"number\"},\"flow_rate_y\":{\"type\":\"number\"},\"flow_x\":{\"type\":\"integer\"},\"flow_y\":{\"type\":\"integer\"},\"ground_distance\":{\"type\":\"number\"},\"quality\":{\"type\":\"integer\"},\"sensor_id\":{\"type\":\"integer\"},\"time_usec\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"covariance\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"pitchspeed\":{\"type\":\"number\"},\"q\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"rollspeed\":{\"type\":\"number\"},\"time_usec\":{\"type\":\"integer\"},\"yawspeed\":{\"type\":\"number\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"airspeed\":{\"type\":\"number\"},\"alt\":{\"type\":\"number\"},\"climb\":{\"type\":\"number\"},\"groundspeed\":{\"type\":\"number\"},\"heading\":{\"type\":\"integer\"},\"throttle\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"hw_unique_id\":{\"type\":\"string\"},\"hw_version_major\":{\"type\":\"integer\"},\"hw_version_minor\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"},\"sw_vcs_commit\":{\"type\":\"integer\"},\"sw_version_major\":{\"type\":\"integer\"},\"sw_version_minor\":{\"type\":\"integer\"},\"time_usec\":{\"type\":\"integer\"},\"uptime_sec\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"param_id\":{\"type\":\"string\"},\"param_index\":{\"type\":\"integer\"},\"target_component\":{\"type\":\"integer\"},\"target_system\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"angle_offset\":{\"type\":\"number\"},\"distances\":{\"items\":{\"type\":\"integer\"},\"type\":\"array\"},\"frame\":{\"type\":\"integer\"},\"increment\":{\"type\":\"integer\"},\"increment_f\":{\"type\":\"number\"},\"max_distance\":{\"type\":\"integer\"},\"min_distance\":{\"type\":\"integer\"},\"sensor_type\":{\"type\":\"integer\"},\"time_usec\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"angle_off\":{\"type\":\"number\"},\"distances\":{\"items\":{\"type\":\"integer\"},\"type\":\"array\"},\"frame\":{\"type\":\"integer\"},\"increment\":{\"type\":\"integer\"},\"increment_f\":{\"type\":\"number\"},\"max_distance\":{\"type\":\"integer\"},\"min_distance\":{\"type\":\"integer\"},\"sensor_type\":{\"type\":\"integer\"},\"time_usec\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"angle_offset\":{\"type\":\"number\"},\"distances\":{\"items\":{\"type\":\"integer\"},\"type\":\"array\"},\"frame\":{\"type\":\"integer\"},\"increment\":{\"type\":\"integer\"},\"increment_f\":{\"type\":\"number\"},\"max_distance\":{\"type\":\"integer\"},\"min_distance\":{\"type\":\"integer\"},\"sensor_type\":{\"type\":\"integer\"},\"time_usec\":{\"type\":\"integer\"}},\"type\":\"object\"}", "{\"$id\":\"/mavlink/topic\",\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"properties\":{\"count\":{\"type\":\"integer\"},\"distance\":{\"items\":{\"type\":\"number\"},\"type\":\"array\"},\"time_usec\":{\"type\":\"integer\"}},\"type\":\"object\"}", } var jsonTest = []string{ "{\"acc_x\":[1,2,3,4,5],\"acc_y\":[1,2,3,4,5],\"acc_z\":[1,2,3,4,5],\"command\":[1,2,3,4,5],\"pos_x\":[1,2,3,4,5],\"pos_y\":[1,2,3,4,5],\"pos_yaw\":[1,2,3,4,5],\"pos_z\":[1,2,3,4,5],\"time_usec\":1,\"valid_points\":2,\"vel_x\":[1,2,3,4,5],\"vel_y\":[1,2,3,4,5],\"vel_yaw\":[1,2,3,4,5],\"vel_z\":[1,2,3,4,5]}", "{\"flow_comp_m_x\":\"nan\",\"flow_comp_m_y\":\"+inf\",\"flow_rate_x\":1,\"flow_rate_y\":1,\"flow_x\":7,\"flow_y\":8,\"ground_distance\":\"-inf\",\"quality\":10,\"sensor_id\":9,\"time_usec\":3}", "{\"covariance\":[1,1,1,1,1,1,1,1,1],\"pitchspeed\":1,\"q\":[1,1,1,1],\"rollspeed\":1,\"time_usec\":2,\"yawspeed\":1}", "{\"airspeed\":1234,\"alt\":1234,\"climb\":1234,\"groundspeed\":1234,\"heading\":12,\"throttle\":123}", "{\"hw_unique_id\":\"AQIDBAUGBwgJCgsMDQ4PEA==\",\"hw_version_major\":3,\"hw_version_minor\":4,\"name\":\"sapog.px4.io\",\"sw_vcs_commit\":7,\"sw_version_major\":5,\"sw_version_minor\":6,\"time_usec\":1,\"uptime_sec\":2}", "{\"param_id\":\"hopefullyWorks\",\"param_index\":333,\"target_component\":2,\"target_system\":1}", "{\"angle_offset\":0,\"distances\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72],\"frame\":0,\"increment\":36,\"increment_f\":0,\"max_distance\":50,\"min_distance\":1,\"sensor_type\":2,\"time_usec\":1}", "{\"angle_offset\":0,\"distances\":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72],\"frame\":0,\"increment\":36,\"increment_f\":0,\"max_distance\":50,\"min_distance\":1,\"sensor_type\":2,\"time_usec\":1}", "{\"angle_offset\":\"invalidString\",\"distances\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72],\"frame\":0,\"increment\":36,\"increment_f\":0,\"max_distance\":50,\"min_distance\":1,\"sensor_type\":2,\"time_usec\":1}", "{\"count\":4,\"distance\":[\"nan\",\"nan\",\"+inf\",\"-inf\",\"nan\",\"nan\",\"+inf\",\"-inf\",\"nan\",\"nan\",\"+inf\",\"-inf\",\"nan\",\"nan\",\"+inf\",\"-inf\"],\"time_usec\":10}", } // Function that is not exported so copy and pasted here for testing purposes. func dialectMsgDefToGo(in string) string { re := regexp.MustCompile("_[a-z]") in = strings.ToLower(in) in = re.ReplaceAllStringFunc(in, func(match string) string { return strings.ToUpper(match[1:2]) }) return strings.ToUpper(in[:1]) + in[1:] } // Test case structs to loop through in testing above. var casesMsgsTest = []struct { name string isV2 bool parsed gomavlib.Message raw []byte id uint32 }{ { "v1 message with array of enums", false, &MessageTrajectoryRepresentationWaypoints{ TimeUsec: 1, ValidPoints: 2, PosX: [5]float32{1, 2, 3, 4, 5}, PosY: [5]float32{1, 2, 3, 4, 5}, PosZ: [5]float32{1, 2, 3, 4, 5}, VelX: [5]float32{1, 2, 3, 4, 5}, VelY: [5]float32{1, 2, 3, 4, 5}, VelZ: [5]float32{1, 2, 3, 4, 5}, AccX: [5]float32{1, 2, 3, 4, 5}, AccY: [5]float32{1, 2, 3, 4, 5}, AccZ: [5]float32{1, 2, 3, 4, 5}, PosYaw: [5]float32{1, 2, 3, 4, 5}, VelYaw: [5]float32{1, 2, 3, 4, 5}, Command: [5]MAV_CMD{1, 2, 3, 4, 5}, }, []byte("\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x00\x00\x80\x3f\x00\x00\x00\x40\x00\x00\x40\x40\x00\x00\x80\x40\x00\x00\xa0\x40\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x02"), 332, }, { "v2 message with extensions", true, &MessageOpticalFlow{ TimeUsec: 3, FlowCompMX: float32(math.NaN()), // Nan FlowCompMY: float32(math.Inf(1)), // + Inf GroundDistance: float32(math.Inf(-1)), // -Inf FlowX: 7, FlowY: 8, SensorId: 9, Quality: 0x0A, FlowRateX: 1, FlowRateY: 1, }, []byte("\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\x7f\x00\x00\x80\x7f\x00\x00\x80\xff\x07\x00\x08\x00\x09\x0a\x00\x00\x80\x3f\x00\x00\x80\x3f"), 100, }, { "v1 message with array", false, &MessageAttitudeQuaternionCov{ TimeUsec: 2, Q: [4]float32{1, 1, 1, 1}, Rollspeed: 1, Pitchspeed: 1, Yawspeed: 1, Covariance: [9]float32{1, 1, 1, 1, 1, 1, 1, 1, 1}, }, append([]byte("\x02\x00\x00\x00\x00\x00\x00\x00"), bytes.Repeat([]byte("\x00\x00\x80\x3F"), 16)...), 61, }, { "V2 message 74", true, &MessageVfrHud{ Airspeed: 1234, Groundspeed: 1234, Heading: 12, Throttle: 123, Alt: 1234, Climb: 1234, }, []byte("\x00\x40\x9A\x44\x00\x40\x9A\x44\x00\x40\x9A\x44\x00\x40\x9A\x44\x0C\x00\x7B"), 74, }, { "V2 Message 311 with string", true, &MessageUavcanNodeInfo{ TimeUsec: 1, UptimeSec: 2, Name: "sapog.px4.io", HwVersionMajor: 3, HwVersionMinor: 4, HwUniqueId: [16]uint8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, SwVersionMajor: 5, SwVersionMinor: 6, SwVcsCommit: 7, }, []byte("\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x07\x00\x00\x00\x73\x61\x70\x6F\x67\x2E\x70\x78\x34\x2E\x69\x6F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x04\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x05\x06"), 311, }, { "V2 Message 320 with string", true, &MessageParamExtRequestRead{ TargetSystem: 1, TargetComponent: 2, ParamId: "hopefullyWorks", ParamIndex: 333, }, []byte("\x4D\x01\x01\x02\x68\x6F\x70\x65\x66\x75\x6C\x6C\x79\x57\x6F\x72\x6B\x73"), 320, }, { "V2 Message 330 with array of uint16", true, &MessageObstacleDistance{ TimeUsec: 1, SensorType: 2, Distances: [72]uint16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, Increment: 36, MinDistance: 1, MaxDistance: 50, IncrementF: 0, AngleOffset: 0, Frame: 0, }, []byte("\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0A\x00\x0B\x00\x0C\x00\x0D\x00\x0E\x00\x0F\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1A\x00\x1B\x00\x1C\x00\x1D\x00\x1E\x00\x1F\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2A\x00\x2B\x00\x2C\x00\x2D\x00\x2E\x00\x2F\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3A\x00\x3B\x00\x3C\x00\x3D\x00\x3E\x00\x3F\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x01\x00\x32\x00\x02\x24"), 330, }, { "V2 Message 330 with array of uint16 - Schema and JSON given should fail for this test case!", true, &MessageObstacleDistance{ TimeUsec: 1, SensorType: 2, Distances: [72]uint16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, Increment: 36, MinDistance: 1, MaxDistance: 50, IncrementF: 0, AngleOffset: 0, Frame: 0, }, []byte("\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0A\x00\x0B\x00\x0C\x00\x0D\x00\x0E\x00\x0F\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1A\x00\x1B\x00\x1C\x00\x1D\x00\x1E\x00\x1F\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2A\x00\x2B\x00\x2C\x00\x2D\x00\x2E\x00\x2F\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3A\x00\x3B\x00\x3C\x00\x3D\x00\x3E\x00\x3F\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x01\x00\x32\x00\x02\x24"), 330, }, { "V2 Message 330 with array of uint16 - JSONTest[8] should not validate to schemasTest[8] for this test case!", true, &MessageObstacleDistance{ TimeUsec: 1, SensorType: 2, Distances: [72]uint16{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, Increment: 36, MinDistance: 1, MaxDistance: 50, IncrementF: 0, AngleOffset: 0, Frame: 0, }, []byte("\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0A\x00\x0B\x00\x0C\x00\x0D\x00\x0E\x00\x0F\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1A\x00\x1B\x00\x1C\x00\x1D\x00\x1E\x00\x1F\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2A\x00\x2B\x00\x2C\x00\x2D\x00\x2E\x00\x2F\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3A\x00\x3B\x00\x3C\x00\x3D\x00\x3E\x00\x3F\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x01\x00\x32\x00\x02\x24"), 330, }, { "V2 message with float64 NaN, +Inf, and -Inf values", true, &MessageWheelDistance{ TimeUsec: 10, Count: 4, Distance: [16]float64{math.NaN(), math.NaN(), math.Inf(1), math.Inf(-1), math.NaN(), math.NaN(), math.Inf(1), math.Inf(-1), math.NaN(), math.NaN(), math.Inf(1), math.Inf(-1), math.NaN(), math.NaN(), math.Inf(1), math.Inf(-1)}, }, []byte("\x0a\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\xf8\x7f\x01\x00\x00\x00\x00\x00\xf8\x7f\x00\x00\x00\x00\x00\x00\xf0\x7f\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\xf8\x7f\x01\x00\x00\x00\x00\x00\xf8\x7f\x00\x00\x00\x00\x00\x00\xf0\x7f\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\xf8\x7f\x01\x00\x00\x00\x00\x00\xf8\x7f\x00\x00\x00\x00\x00\x00\xf0\x7f\x00\x00\x00\x00\x00\x00\xf0\xff\x01\x00\x00\x00\x00\x00\xf8\x7f\x01\x00\x00\x00\x00\x00\xf8\x7f\x00\x00\x00\x00\x00\x00\xf0\x7f\x00\x00\x00\x00\x00\x00\xf0\xff\x04"), 9000, }, } var ctMessages = []gomavlib.Message{ // common.xml &MessageHeartbeat{}, &MessageSysStatus{}, &MessageSystemTime{}, &MessagePing{}, &MessageChangeOperatorControl{}, &MessageChangeOperatorControlAck{}, &MessageAuthKey{}, &MessageLinkNodeStatus{}, &MessageSetMode{}, &MessageParamRequestRead{}, &MessageParamRequestList{}, &MessageParamValue{}, &MessageParamSet{}, &MessageGpsRawInt{}, &MessageGpsStatus{}, &MessageScaledImu{}, &MessageRawImu{}, &MessageRawPressure{}, &MessageScaledPressure{}, &MessageAttitude{}, &MessageAttitudeQuaternion{}, &MessageLocalPositionNed{}, &MessageGlobalPositionInt{}, &MessageRcChannelsScaled{}, &MessageRcChannelsRaw{}, &MessageServoOutputRaw{}, &MessageMissionRequestPartialList{}, &MessageMissionWritePartialList{}, &MessageMissionItem{}, &MessageMissionRequest{}, &MessageMissionSetCurrent{}, &MessageMissionCurrent{}, &MessageMissionRequestList{}, &MessageMissionCount{}, &MessageMissionClearAll{}, &MessageMissionItemReached{}, &MessageMissionAck{}, &MessageSetGpsGlobalOrigin{}, &MessageGpsGlobalOrigin{}, &MessageParamMapRc{}, &MessageMissionRequestInt{}, &MessageMissionChanged{}, &MessageSafetySetAllowedArea{}, &MessageSafetyAllowedArea{}, &MessageAttitudeQuaternionCov{}, &MessageNavControllerOutput{}, &MessageGlobalPositionIntCov{}, &MessageLocalPositionNedCov{}, &MessageRcChannels{}, &MessageRequestDataStream{}, &MessageDataStream{}, &MessageManualControl{}, &MessageRcChannelsOverride{}, &MessageMissionItemInt{}, &MessageVfrHud{}, &MessageCommandInt{}, &MessageCommandLong{}, &MessageCommandAck{}, &MessageManualSetpoint{}, &MessageSetAttitudeTarget{}, &MessageAttitudeTarget{}, &MessageSetPositionTargetLocalNed{}, &MessagePositionTargetLocalNed{}, &MessageSetPositionTargetGlobalInt{}, &MessagePositionTargetGlobalInt{}, &MessageLocalPositionNedSystemGlobalOffset{}, &MessageHilState{}, &MessageHilControls{}, &MessageHilRcInputsRaw{}, &MessageHilActuatorControls{}, &MessageOpticalFlow{}, &MessageGlobalVisionPositionEstimate{}, &MessageVisionPositionEstimate{}, &MessageVisionSpeedEstimate{}, &MessageViconPositionEstimate{}, &MessageHighresImu{}, &MessageOpticalFlowRad{}, &MessageHilSensor{}, &MessageSimState{}, &MessageRadioStatus{}, &MessageFileTransferProtocol{}, &MessageTimesync{}, &MessageCameraTrigger{}, &MessageHilGps{}, &MessageHilOpticalFlow{}, &MessageHilStateQuaternion{}, &MessageScaledImu2{}, &MessageLogRequestList{}, &MessageLogEntry{}, &MessageLogRequestData{}, &MessageLogData{}, &MessageLogErase{}, &MessageLogRequestEnd{}, &MessageGpsInjectData{}, &MessageGps2Raw{}, &MessagePowerStatus{}, &MessageSerialControl{}, &MessageGpsRtk{}, &MessageGps2Rtk{}, &MessageScaledImu3{}, &MessageDataTransmissionHandshake{}, &MessageEncapsulatedData{}, &MessageDistanceSensor{}, &MessageTerrainRequest{}, &MessageTerrainData{}, &MessageTerrainCheck{}, &MessageTerrainReport{}, &MessageScaledPressure2{}, &MessageAttPosMocap{}, &MessageSetActuatorControlTarget{}, &MessageActuatorControlTarget{}, &MessageAltitude{}, &MessageResourceRequest{}, &MessageScaledPressure3{}, &MessageFollowTarget{}, &MessageControlSystemState{}, &MessageBatteryStatus{}, &MessageAutopilotVersion{}, &MessageLandingTarget{}, &MessageFenceStatus{}, &MessageEstimatorStatus{}, &MessageWindCov{}, &MessageGpsInput{}, &MessageGpsRtcmData{}, &MessageHighLatency{}, &MessageHighLatency2{}, &MessageVibration{}, &MessageHomePosition{}, &MessageSetHomePosition{}, &MessageMessageInterval{}, &MessageExtendedSysState{}, &MessageAdsbVehicle{}, &MessageCollision{}, &MessageV2Extension{}, &MessageMemoryVect{}, &MessageDebugVect{}, &MessageNamedValueFloat{}, &MessageNamedValueInt{}, &MessageStatustext{}, &MessageDebug{}, &MessageSetupSigning{}, &MessageButtonChange{}, &MessagePlayTune{}, &MessageCameraInformation{}, &MessageCameraSettings{}, &MessageStorageInformation{}, &MessageCameraCaptureStatus{}, &MessageCameraImageCaptured{}, &MessageFlightInformation{}, &MessageMountOrientation{}, &MessageLoggingData{}, &MessageLoggingDataAcked{}, &MessageLoggingAck{}, &MessageVideoStreamInformation{}, &MessageVideoStreamStatus{}, &MessageWifiConfigAp{}, &MessageProtocolVersion{}, &MessageAisVessel{}, &MessageUavcanNodeStatus{}, &MessageUavcanNodeInfo{}, &MessageParamExtRequestRead{}, &MessageParamExtRequestList{}, &MessageParamExtValue{}, &MessageParamExtSet{}, &MessageParamExtAck{}, &MessageObstacleDistance{}, &MessageOdometry{}, &MessageTrajectoryRepresentationWaypoints{}, &MessageTrajectoryRepresentationBezier{}, &MessageCellularStatus{}, &MessageIsbdLinkStatus{}, &MessageUtmGlobalPosition{}, &MessageDebugFloatArray{}, &MessageOrbitExecutionStatus{}, &MessageSmartBatteryInfo{}, &MessageSmartBatteryStatus{}, &MessageActuatorOutputStatus{}, &MessageTimeEstimateToTarget{}, &MessageTunnel{}, &MessageOnboardComputerStatus{}, &MessageComponentInformation{}, &MessagePlayTuneV2{}, &MessageSupportedTunes{}, &MessageWheelDistance{}, &MessageOpenDroneIdBasicId{}, &MessageOpenDroneIdLocation{}, &MessageOpenDroneIdAuthentication{}, &MessageOpenDroneIdSelfId{}, &MessageOpenDroneIdSystem{}, &MessageOpenDroneIdOperatorId{}, &MessageOpenDroneIdMessagePack{}, } // DEFINE PUBLIC RECEIVER FUNCTIONS. // DEFINE PRIVATE STATIC FUNCTIONS. // DEFINE PRIVATE RECEIVER FUNCTIONS. // ALL DONE.
testgomavlib/dialectRTTestFunctions.go
0.562417
0.410284
dialectRTTestFunctions.go
starcoder
package trueskill import ( "errors" "fmt" "math" "github.com/chobie/go-gaussian" "github.com/gami/go-trueskill/factorgraph" "github.com/gami/go-trueskill/mathmatics" ) const ( defaultMu = 25.0 defaultSigmaDenom = 3 defaultBetaDenom = 2 defaultTauDenom = 100 defaultDrawProbability = 0.1 // MinDelta is a basis to check reliability of the result. MinDelta = 0.001 ) // TrueSkill represents envirionment of rating type TrueSkill struct { mu float64 // the initial mean of ratings. sigma float64 // the initial standard deviation of ratings. The recommended value is a third of mu. beta float64 // the distance which guarantees about 76% chance of winning. The recommended value is a half of sigma. tau float64 // the dynamic factor which restrains a fixation of rating. The recommended value is sigma per cent. drawProbability float64 // the draw probability between two teams. It can be a float or function which returns a float by the given two rating (team performance) arguments and the beta value. If it is a float, the game has fixed draw probability. Otherwise, the draw probability will be decided dynamically per each match. } type option func(*TrueSkill) func NewTrueSkill(options ...option) *TrueSkill { s := &TrueSkill{ mu: defaultMu, drawProbability: defaultDrawProbability, } for _, opt := range options { opt(s) } if s.sigma == 0 { s.sigma = s.mu / defaultSigmaDenom } if s.beta == 0 { s.beta = s.sigma / defaultBetaDenom } if s.tau == 0 { s.tau = s.sigma / defaultTauDenom } return s } func MU(v float64) option { return func(s *TrueSkill) { s.mu = v } } func Sigma(v float64) option { return func(s *TrueSkill) { s.sigma = v } } func Beta(v float64) option { return func(s *TrueSkill) { s.beta = v } } func Tau(v float64) option { return func(s *TrueSkill) { s.tau = v } } func DrawProbability(v float64) option { return func(s *TrueSkill) { s.drawProbability = v } } func (s *TrueSkill) CreateRating() *Rating { return NewRating(s.mu, s.sigma, 1) } // Rate recalculates ratings by the ranking table: func (s *TrueSkill) Rate(ratingGroups [][]*Rating) ([][]*Rating, error) { if err := s.validateRatingGroup(ratingGroups); err != nil { return nil, err } flattenRatings := make([]*Rating, 0) sortedRanks := make([]int, 0) rank := 0 for _, rg := range ratingGroups { for _, r := range rg { flattenRatings = append(flattenRatings, r) sortedRanks = append(sortedRanks, rank) } rank++ } ratingVars := make([]*factorgraph.Variable, 0, len(flattenRatings)) perfVars := make([]*factorgraph.Variable, 0, len(flattenRatings)) flattenWeights := make([]float64, 0, len(flattenRatings)) for _, r := range flattenRatings { ratingVars = append(ratingVars, factorgraph.NewVariable(mathmatics.NewGaussian(0, 0))) perfVars = append(perfVars, factorgraph.NewVariable(mathmatics.NewGaussian(0, 0))) flattenWeights = append(flattenWeights, r.Weight) } teamPerfVars := make([]*factorgraph.Variable, 0, len(ratingGroups)) for i := 0; i < len(ratingGroups); i++ { teamPerfVars = append(teamPerfVars, factorgraph.NewVariable(mathmatics.NewGaussian(0, 0))) } teamDiffVars := make([]*factorgraph.Variable, 0, len(ratingGroups)-1) for i := 0; i < len(ratingGroups)-1; i++ { teamDiffVars = append(teamDiffVars, factorgraph.NewVariable(mathmatics.NewGaussian(0, 0))) } teamSizes := teamSizes(ratingGroups) layers, err := s.runSchedule( ratingVars, flattenRatings, perfVars, teamPerfVars, teamSizes, flattenWeights, teamDiffVars, sortedRanks, ratingGroups, ) if err != nil { return nil, err } transformedGroups := make([][]*Rating, 0, len(teamSizes)) trimmed := []int{0} trimmed = append(trimmed, teamSizes[0:len(teamSizes)-1]...) for i := 0; i < len(teamSizes); i++ { group := make([]*Rating, 0) glayers := layers[trimmed[i]:teamSizes[i]] for _, layer := range glayers { r := NewRating(layer.Var().Mu(), layer.Var().Sigma(), 1) group = append(group, r) } transformedGroups = append(transformedGroups, group) } return transformedGroups, nil } func (s *TrueSkill) validateRatingGroup(ratingGroups [][]*Rating) error { if len(ratingGroups) < 2 { return errors.New("need multiple rating groups") } for _, rs := range ratingGroups { if len(rs) < 1 { return errors.New("each group must contain multiple ratings") } } return nil } // Expose returns the value of the rating exposure. It starts from 0 and // converges to the mean. func (s *TrueSkill) Expose(r *Rating) float64 { k := s.mu / s.sigma return r.Mu - k*r.Sigma } // Rate1v1 is a shortcut to rate just 2 players in a head-to-head match func (s *TrueSkill) Rate1v1( win *Rating, lose *Rating, ) ([]*Rating, error) { teams, err := s.Rate([][]*Rating{{win}, {lose}}) if err != nil { return nil, err } return []*Rating{teams[0][0], teams[1][0]}, nil } // runSchedule sends messages within every nodes of the factor graph until the result is reliable. func (s *TrueSkill) runSchedule( ratingVars []*factorgraph.Variable, flattenRatings []*Rating, perfVars []*factorgraph.Variable, teamPerfVars []*factorgraph.Variable, teamSizes []int, flattenWeights []float64, teamDiffVars []*factorgraph.Variable, sortedRanks []int, sortedRatingGroups [][]*Rating, ) ([]*factorgraph.PriorFactor, error) { ratingLayer := s.buildRatingLayer(ratingVars, flattenRatings) perfLayer := s.buildPerfLayer(ratingVars, perfVars) teamPerfLayer := s.buildTeamPerfLayer( teamPerfVars, perfVars, teamSizes, flattenWeights, ) for _, f := range ratingLayer { f.Down() } for _, f := range perfLayer { f.Down() } for _, f := range teamPerfLayer { f.Down() } // Arrow #1, #2, #3 teamDiffLayer := s.buildTeamDiffLayer(teamPerfVars, teamDiffVars) truncLayer := s.buildTruncLayer(teamDiffVars, sortedRanks, sortedRatingGroups) teamDiffLen := len(teamDiffLayer) for index := 0; index <= 10; index++ { delta := 0.0 var err error if teamDiffLen == 1 { // Only two teams teamDiffLayer[0].Down() delta, err = truncLayer[0].Up() if err != nil { return nil, err } } else { // Multiple teams for z := 0; z < teamDiffLen-1; z++ { teamDiffLayer[z].Down() d, err := truncLayer[z].Up() if err != nil { return nil, err } delta = math.Max(delta, d) teamDiffLayer[z].SetPointer(1) teamDiffLayer[z].Up() } for z := teamDiffLen - 1; z > 0; z-- { teamDiffLayer[z].Down() d, err := truncLayer[z].Up() if err != nil { return nil, err } delta = math.Max(delta, d) teamDiffLayer[z].SetPointer(0) teamDiffLayer[z].Up() } } // Repeat until too small update if delta <= MinDelta { break } } // Up both ends teamDiffLayer[0].SetPointer(0) teamDiffLayer[0].Up() teamDiffLayer[teamDiffLen-1].SetPointer(1) teamDiffLayer[teamDiffLen-1].Up() // Up the remainder of the black arrows for _, f := range teamPerfLayer { f.SetPointer(0) for x := 0; x < len(f.Vars)-1; x++ { f.Up() } } for _, f := range perfLayer { f.Up() } return ratingLayer, nil } func (s *TrueSkill) buildRatingLayer(ratingVars []*factorgraph.Variable, flattenRatings []*Rating) []*factorgraph.PriorFactor { layers := make([]*factorgraph.PriorFactor, 0, len(ratingVars)) for i, v := range ratingVars { f := factorgraph.NewPriorFactor(v, flattenRatings[i].gaussian(), s.tau) layers = append(layers, f) } return layers } func (s *TrueSkill) buildPerfLayer(ratingVars []*factorgraph.Variable, perfVars []*factorgraph.Variable) []factorgraph.Factor { layer := make([]factorgraph.Factor, 0, len(ratingVars)) b := math.Pow(s.beta, 2) for i, v := range ratingVars { f := factorgraph.NewLikelihoodFactor(v, perfVars[i], b) layer = append(layer, f) } return layer } func (s *TrueSkill) buildTeamPerfLayer( teamPerfVars []*factorgraph.Variable, perfVars []*factorgraph.Variable, teamSizes []int, flattenWeights []float64, ) []*factorgraph.SumFactor { team := 0 layer := make([]*factorgraph.SumFactor, 0, len(teamPerfVars)) for _, v := range teamPerfVars { s := 0 if team > 0 { s = teamSizes[team-1] } e := teamSizes[team] team++ f := factorgraph.NewSumFactor(v, perfVars[s:e], flattenWeights[s:e]) layer = append(layer, f) } return layer } func (s *TrueSkill) buildTeamDiffLayer(teamPerfVars []*factorgraph.Variable, teamDiffVars []*factorgraph.Variable) []*factorgraph.SumFactor { layer := make([]*factorgraph.SumFactor, 0, len(teamDiffVars)) team := 0 for _, v := range teamDiffVars { sl := teamPerfVars[team : team+2] team++ f := factorgraph.NewSumFactor(v, sl, []float64{1, -1}) layer = append(layer, f) } return layer } func (s *TrueSkill) buildTruncLayer( teamDiffVars []*factorgraph.Variable, sortedRanks []int, sortedRatingGroups [][]*Rating, ) []factorgraph.Factor { x := 0 layer := make([]factorgraph.Factor, 0, len(teamDiffVars)) for _, v := range teamDiffVars { size := 0 for _, r := range sortedRatingGroups[x : x+2] { size += len(r) } drawMargin := s.calcDrawMargin(size) vFunc := func(a float64, b float64) float64 { return s.vWin(a, b) } wFunc := func(a float64, b float64) (float64, error) { return s.wWin(a, b) } if sortedRanks[x] == sortedRanks[x+1] { vFunc = func(a float64, b float64) float64 { return s.vDraw(a, b) } wFunc = func(a float64, b float64) (float64, error) { return s.wDraw(a, b) } } x++ f := factorgraph.NewTruncateFactor(v, vFunc, wFunc, drawMargin) layer = append(layer, f) } return layer } func (s *TrueSkill) calcDrawMargin( size int, ) float64 { g := gaussian.NewGaussian(0.0, 1.0) return g.Ppf((s.drawProbability+1.0)/2.0) * math.Sqrt(float64(size)) * s.beta } // The non-draw version of "V" function. // "V" calculates a variation of a mean. func (s *TrueSkill) vWin(diff float64, drawMargin float64) float64 { x := diff - drawMargin g := gaussian.NewGaussian(0.0, 1.0) denom := g.Cdf(x) if denom != 0 && !math.IsNaN(denom) { return g.Pdf(x) / denom } return -1 * x } // The draw version of "v" function. func (s *TrueSkill) vDraw(diff float64, drawMargin float64) float64 { absDiff := math.Abs(diff) a := drawMargin - absDiff b := -1*drawMargin - absDiff g := gaussian.NewGaussian(0.0, 1.0) denom := g.Cdf(a) - g.Cdf(b) numer := g.Pdf(b) - g.Pdf(a) if denom != 0 && !math.IsNaN(denom) { if diff < 0 { return (numer / denom) * -1 } return (numer / denom) } if diff < 0 { return a * -1 } return a } // The non-draw version of "W" function. // "W" calculates a variation of a standard deviation. func (s *TrueSkill) wWin(diff float64, drawMargin float64) (float64, error) { x := diff - drawMargin v := s.vWin(diff, drawMargin) w := v * (v + x) if w > 0 && w < 1 { return w, nil } return 0, fmt.Errorf("wWin floating point error w=%v diff=%v drawMargin=%v", w, diff, drawMargin) } // The draw version of "w" function. func (s *TrueSkill) wDraw(diff float64, drawMargin float64) (float64, error) { absDiff := math.Abs(diff) a := drawMargin - absDiff b := -1*drawMargin - absDiff g := gaussian.NewGaussian(0.0, 1.0) denom := g.Cdf(a) - g.Cdf(b) if denom == 0 || math.IsNaN(denom) { return 0, fmt.Errorf("wWin floating point error denom=%v", denom) } v := s.vDraw(absDiff, drawMargin) return math.Pow(v, 2) + (a*g.Pdf(a)-b*g.Pdf(b))/denom, nil } // Makes a size map of each teams. func teamSizes(ratingGroups [][]*Rating) []int { teamSizes := make([]int, 0, len(ratingGroups)) size := 0 for _, r := range ratingGroups { teamSizes = append(teamSizes, size+len(r)) size += len(r) } return teamSizes }
trueskill.go
0.715921
0.592784
trueskill.go
starcoder
package field import ( "math" "github.com/csweichel/go-pen/pkg/plot" "github.com/aquilax/go-perlin" ) // NewVectorField produces a new vector field from vectors func NewVectorField(counts, spacing plot.XY, sampler func(p plot.XY) Vector) *VectorField { res := make([][]Vector, counts.X) for x := 0; x < counts.X; x++ { res[x] = make([]Vector, counts.Y) for y := 0; y < counts.Y; y++ { res[x][y] = sampler(plot.XY{X: x * spacing.X, Y: y * spacing.Y}) } } return &VectorField{ Points: res, Spacing: spacing, } } // VectorField represents a vector field type VectorField struct { Points [][]Vector Spacing plot.XY } // Finds the nearest point in the field. If the point is outside the field // this function will return nil. func (f *VectorField) Nearest(p plot.XY) *Vector { var ( x = p.X / f.Spacing.X y = p.Y / f.Spacing.Y ) if x < 0 || x >= len(f.Points) { return nil } col := f.Points[x] if y < 0 || y >= len(col) { return nil } return &col[y] } // Draw draws the field as a set of lines func (field *VectorField) Draw(offset plot.XY) []plot.Drawable { res := make([]plot.Drawable, 0, len(field.Points)) for x, xs := range field.Points { for y, p := range xs { s := plot.XY{X: x*field.Spacing.X + offset.X, Y: y*field.Spacing.Y + offset.Y} res = append(res, plot.Line{ Start: s, End: s.AddF(float64(p.Length)*math.Sin(p.Angle), float64(p.Length)*math.Cos(p.Angle)), }) } } return res } // Vector represents a vector with a starting point, angle and length type Vector struct { Angle float64 Length int } // NewPerlinNoiseField produces a new vector field spread across the canvas, where the angles are determined // using Perlin noise. The counts determines the number of points in the vector field along X and Y. // Alpha, beta, n and seed are perlin noise generator parameters. func NewPerlinNoiseField(p plot.Canvas, counts plot.XY, alpha, beta float64, n int32, seed int64) *VectorField { var ( inner = p.Inner() dx = float64(inner.X) / float64(counts.X-1) dy = float64(inner.Y) / float64(counts.Y-1) spacing = plot.XY{X: int(dx), Y: int(dy)} ) gen := perlin.NewPerlin(alpha, beta, n, seed) return NewVectorField(counts, spacing, func(pos plot.XY) Vector { ns := gen.Noise2D(float64(pos.X)/float64(inner.X), float64(pos.Y)/float64(inner.Y)) angle := 2 * math.Pi * ns return Vector{ Angle: angle, Length: 35, } }) } // TraceLine traces a line from the starting point following the angles of the nearest points until // we've reached "steps" line count.s func TraceLine(p plot.Canvas, field *VectorField, start plot.XY, len, steps int) (r []plot.Line) { if steps <= 0 { return } nearest := field.Nearest(start) if nearest == nil { return } angle := nearest.Angle end := start.Add(int(float64(len)*math.Cos(angle)), int(float64(len)*math.Sin(angle))) r = append(r, TraceLine(p, field, end, len, steps-1)...) r = append(r, plot.Line{ Start: start.AddXY(p.Bleed), End: end.AddXY(p.Bleed), }) return }
pkg/field/field.go
0.853058
0.708112
field.go
starcoder
package slippy import "math" // ==== lat lon (aka WGS 84) ==== // Lat2Tile takes a zoom and a lat to produce the lon func Lat2Tile(zoom uint, lat float64) (y uint) { latRad := lat * math.Pi / 180 return uint(math.Exp2(float64(zoom))* (1.0-math.Log( math.Tan(latRad)+ (1/math.Cos(latRad)))/math.Pi)) / 2.0 } // Lon2Tile takes in a zoom and lon to produce the lat func Lon2Tile(zoom uint, lon float64) (x uint) { return uint(math.Exp2(float64(zoom)) * (lon + 180.0) / 360.0) } // Tile2Lon will return the west most longitude func Tile2Lon(zoom, x uint) float64 { return float64(x)/math.Exp2(float64(zoom))*360.0 - 180.0 } // Tile2Lat will return the north most latitude func Tile2Lat(zoom, y uint) float64 { var n float64 = math.Pi if y != 0 { n = math.Pi - 2.0*math.Pi*float64(y)/math.Exp2(float64(zoom)) } return 180.0 / math.Pi * math.Atan(0.5*(math.Exp(n)-math.Exp(-n))) } // ==== Web Mercator ==== // WebMercatorMax is the max size in meters of a tile const WebMercatorMax = 20037508.34 // Tile2WebX returns the side of the tile in the -x side func Tile2WebX(zoom uint, n uint) float64 { res := (WebMercatorMax * 2) / math.Exp2(float64(zoom)) return -WebMercatorMax + float64(n)*res } // Tile2WebY returns the side of the tile in the +y side func Tile2WebY(zoom uint, n uint) float64 { res := (WebMercatorMax * 2) / math.Exp2(float64(zoom)) return WebMercatorMax - float64(n)*res } // WebX2Tile returns the column of the tile given the web mercator x value func WebX2Tile(zoom uint, x float64) uint { res := (WebMercatorMax * 2) / math.Exp2(float64(zoom)) return uint((x + WebMercatorMax) / res) } // WebY2Tile returns the row of the tile given the web mercator y value func WebY2Tile(zoom uint, y float64) uint { res := (WebMercatorMax * 2) / math.Exp2(float64(zoom)) return uint(-(y - WebMercatorMax) / res) } // ==== pixels ==== // MvtTileDim is the number of pixels in a tile const MvtTileDim = 4096.0 // Pixels2Webs scalar conversion of pixels into web mercator units // TODO (@ear7h): perhaps rethink this func Pixels2Webs(zoom uint, pixels uint) float64 { return WebMercatorMax * 2 / math.Exp2(float64(zoom)) * float64(pixels) / MvtTileDim }
vendor/github.com/go-spatial/geom/slippy/projections.go
0.715821
0.633226
projections.go
starcoder
package data import ( "fmt" "math" ) import "strconv" const maxDigits = 6 func ff(x float64) string { minExact := strconv.FormatFloat(x, 'g', -1, 64) fixed := strconv.FormatFloat(x, 'g', maxDigits, 64) if len(minExact) < len(fixed) { return minExact } return fixed } type Bin struct { LeftInclusive float64 Right float64 RightInclusive bool Count uint64 CountNorm float64 } func (b *Bin) String() string { if b.RightInclusive { return fmt.Sprintf("[%s,%s]", ff(b.LeftInclusive), ff(b.Right)) } return fmt.Sprintf("[%s,%s)", ff(b.LeftInclusive), ff(b.Right)) } type Bins struct { Number int min, max float64 numPoints int } func BinsSqrt(numPoints int) int { return int(math.Sqrt(float64(numPoints))) } func BinsSturges(numPoints int) int { return int(math.Ceil(math.Log2(float64(numPoints))) + 1) } func BinsRice(numPoints int) int { return int(math.Ceil(2 * math.Pow(float64(numPoints), 1.0/3.0))) } func NewBins(points []float64) *Bins { bins := new(Bins) bins.numPoints = len(points) bins.Number = 5 bins.min = math.Inf(1) bins.max = math.Inf(-1) for _, x := range points { bins.min = math.Min(bins.min, x) bins.max = math.Max(bins.max, x) } return bins } func (b *Bins) left(i int) float64 { return b.min + ((b.max - b.min) / float64(b.Number) * float64(i)) } func (b *Bins) right(i int) float64 { return b.left(i + 1) } func (b *Bins) All() (out []Bin) { if b.max == b.min { b.Number = 1 } for i := 0; i < b.Number; i++ { out = append(out, Bin{ LeftInclusive: b.left(i), Right: b.right(i), }) } out[b.Number-1].RightInclusive = true return } func (b *Bins) Point(x float64) int { if b.max == b.min { return 0 } i := int((x - b.min) / (b.max - b.min) * float64(b.Number)) if i >= b.Number { i-- } return i } func Histogram(points []float64, bins *Bins) (out []Bin) { out = bins.All() for _, b := range out { b.Count = 0 } for _, x := range points { out[bins.Point(x)].Count++ } return } type Bins2D struct { X *Bins Y *Bins } func NewBins2D(points [][2]float64) *Bins2D { bins := new(Bins2D) xs := make([]float64, len(points)) ys := make([]float64, len(points)) for i := range points { xs[i] = points[i][0] ys[i] = points[i][1] } bins.X = NewBins(xs) bins.Y = NewBins(ys) return bins } func Histogram2D(points [][2]float64, bins *Bins2D) (x, y []Bin, z [][]uint64) { x = bins.X.All() y = bins.Y.All() z = make([][]uint64, len(y)) for _, b := range x { b.Count = 0 } for i, b := range y { z[i] = make([]uint64, len(x)) b.Count = 0 } for _, p := range points { i := bins.X.Point(p[0]) j := bins.Y.Point(p[1]) x[i].Count++ y[j].Count++ z[i][j]++ } return }
pkg/data/histogram.go
0.591959
0.508605
histogram.go
starcoder
package geoutil import ( "fmt" "github.com/golang/geo/s1" "github.com/golang/geo/s2" ) const ( PrecisionMax = 0 PrecisionE5 = iota PrecisionE6 = iota PrecisionE7 = iota ) func precisionMax(a s1.Angle) float64 { return a.Degrees() } func precisionE5(a s1.Angle) float64 { return float64(a.E5()) / 1e5 } func precisionE6(a s1.Angle) float64 { return float64(a.E6()) / 1e6 } func precisionE7(a s1.Angle) float64 { return float64(a.E7()) / 1e7 } func selectPrecisionFunc(precision int) (func(s1.Angle) float64, error) { switch precision { case PrecisionMax: return precisionMax, nil case PrecisionE5: return precisionE5, nil case PrecisionE6: return precisionE6, nil case PrecisionE7: return precisionE7, nil default: return nil, fmt.Errorf("geoutil: invalid precision level %d", precision) } } func pointCoordinates(point s2.Point, precisionFunc func(s1.Angle) float64) []float64 { latLng := s2.LatLngFromPoint(point) return []float64{ precisionFunc(latLng.Lng), precisionFunc(latLng.Lat), } } func PointCoordinates(point s2.Point, precision int) ([]float64, error) { precisionFunc, err := selectPrecisionFunc(precision) if err != nil { return nil, err } return pointCoordinates(point, precisionFunc), nil } func loopCoordinates(loop *s2.Loop, precisionFunc func(s1.Angle) float64) [][]float64 { nv := loop.NumVertices() if nv == 0 { return [][]float64{} } lcs := make([][]float64, nv+1) for j := 0; j < nv; j++ { lcs[j] = pointCoordinates(loop.OrientedVertex(j), precisionFunc) } lcs[nv] = lcs[0] return lcs } func LoopCoordinates(loop *s2.Loop, precision int) ([][]float64, error) { precisionFunc, err := selectPrecisionFunc(precision) if err != nil { return nil, err } return loopCoordinates(loop, precisionFunc), nil } func PolygonCoordinates(polygon *s2.Polygon, precision int) ([][][][]float64, error) { precisionFunc, err := selectPrecisionFunc(precision) if err != nil { return nil, err } // Count the number of shells. ns := 0 nl := polygon.NumLoops() for i := 0; i < nl; i++ { if !polygon.Loop(i).IsHole() { ns++ } } mpcs := make([][][][]float64, 0, ns) for i := 0; i < nl; { pcs := make([][][]float64, 0, 1) hole := false for ; i < nl; i++ { loop := polygon.Loop(i) if hole && !loop.IsHole() { break } pcs = append(pcs, loopCoordinates(loop, precisionFunc)) // The next loop, if there is one, should represent a hole. hole = true } mpcs = append(mpcs, pcs) } return mpcs, nil } func unmarshalLatLng(latLng *s2.LatLng, coords []float64) error { if d := len(coords); d != 2 { return fmt.Errorf("geoutil: cannot process coordinates with dimension %d", d) } *latLng = s2.LatLngFromDegrees(coords[1], coords[0]) return nil } func unmarshalPoint(point *s2.Point, coords []float64) error { latLng := s2.LatLng{} if err := unmarshalLatLng(&latLng, coords); err != nil { return err } *point = s2.PointFromLatLng(latLng) return nil } func unmarshalLoops(loops *[]*s2.Loop, polygonCoords [][][]float64) error { shell := len(*loops) for _, linearRingCoords := range polygonCoords { points := make([]s2.Point, 0, len(linearRingCoords)) for _, pointCoords := range linearRingCoords { point := s2.Point{} if err := unmarshalPoint(&point, pointCoords); err != nil { return err } points = append(points, point) } // S2 loops are not required to repeat the closing point. if j := len(points) - 1; points[0] == points[j] { points = points[:j] } // Build the loop and verify the winding order. loop := s2.LoopFromPoints(points) switch { case len(*loops) <= shell: loop.Normalize() case loop.ContainsPoint((*loops)[shell].Vertex(0)): loop.Invert() } *loops = append(*loops, loop) } return nil } func PointFromPointCoordinates(coords []float64) (s2.Point, error) { point := s2.Point{} if err := unmarshalPoint(&point, coords); err != nil { return s2.Point{}, err } return point, nil } func PolylineFromLineStringCoordinates(coords [][]float64) (*s2.Polyline, error) { latLngs := make([]s2.LatLng, len(coords)) for i, pointCoords := range coords { if err := unmarshalLatLng(&latLngs[i], pointCoords); err != nil { return nil, err } } return s2.PolylineFromLatLngs(latLngs), nil } func PolygonFromPolygonCoordinates(coords [][][]float64) (*s2.Polygon, error) { loops := make([]*s2.Loop, 0, len(coords)) if err := unmarshalLoops(&loops, coords); err != nil { return nil, err } return s2.PolygonFromLoops(loops), nil } func PointsFromMultiPointCoordinates(coords [][]float64) ([]s2.Point, error) { points := make([]s2.Point, len(coords)) for i, pointCoords := range coords { if err := unmarshalPoint(&points[i], pointCoords); err != nil { return nil, err } } return points, nil } func PolylinesFromMultiLineStringCoordinates(coords [][][]float64) ([]*s2.Polyline, error) { polylines := make([]*s2.Polyline, len(coords)) for i, lineStringCoords := range coords { polyline, err := PolylineFromLineStringCoordinates(lineStringCoords) if err != nil { return nil, err } polylines[i] = polyline } return polylines, nil } func PolygonFromMultiPolygonCoordinates(coords [][][][]float64) (*s2.Polygon, error) { loops := make([]*s2.Loop, 0, len(coords)) for _, polygonCoords := range coords { if err := unmarshalLoops(&loops, polygonCoords); err != nil { return nil, err } } return s2.PolygonFromLoops(loops), nil }
geoutil.go
0.801354
0.462412
geoutil.go
starcoder
package proto2gql import ( "go/build" "path/filepath" "reflect" "strings" "github.com/pkg/errors" "github.com/EGT-Ukraine/go2gql/generator/plugins/graphql" "github.com/EGT-Ukraine/go2gql/generator/plugins/proto2gql/parser" ) var goTypesScalars = map[string]graphql.GoType{ "double": {Scalar: true, Kind: reflect.Float64}, "float": {Scalar: true, Kind: reflect.Float32}, "bool": {Scalar: true, Kind: reflect.Bool}, "string": {Scalar: true, Kind: reflect.String}, "int64": {Scalar: true, Kind: reflect.Int64}, "sfixed64": {Scalar: true, Kind: reflect.Int64}, "sint64": {Scalar: true, Kind: reflect.Int64}, "int32": {Scalar: true, Kind: reflect.Int32}, "sfixed32": {Scalar: true, Kind: reflect.Int32}, "sint32": {Scalar: true, Kind: reflect.Int32}, "uint32": {Scalar: true, Kind: reflect.Uint32}, "fixed32": {Scalar: true, Kind: reflect.Uint32}, "uint64": {Scalar: true, Kind: reflect.Uint64}, "fixed64": {Scalar: true, Kind: reflect.Uint64}, } func (g *Proto2GraphQL) goTypeByParserType(typ parser.Type) (_ graphql.GoType, err error) { switch pType := typ.(type) { case *parser.ScalarType: res, ok := goTypesScalars[pType.ScalarName] if !ok { err = errors.New("unknown scalar") return } return res, nil case *parser.MapType: keyT, err := g.goTypeByParserType(pType.Map.KeyType) if err != nil { return graphql.GoType{}, errors.Wrap(err, "failed to resolve key type") } valueT, err := g.goTypeByParserType(pType.Map.ValueType) if err != nil { return graphql.GoType{}, errors.Wrap(err, "failed to resolve value type") } return graphql.GoType{ Pkg: pType.File().GoPackage, Kind: reflect.Map, ElemType: &keyT, Elem2Type: &valueT, }, nil case *parser.MessageType: file, err := g.parsedFile(pType.File()) if err != nil { err = errors.Wrap(err, "failed to resolve type parsed file") return graphql.GoType{}, err } msgType := &graphql.GoType{ Pkg: file.GRPCSourcesPkg, Name: snakeCamelCaseSlice(pType.Message.TypeName), Kind: reflect.Struct, } return graphql.GoType{ Pkg: file.GRPCSourcesPkg, Kind: reflect.Ptr, ElemType: msgType, }, nil case *parser.EnumType: file, err := g.parsedFile(pType.File()) if err != nil { err = errors.Wrap(err, "failed to resolve type parsed file") return graphql.GoType{}, err } return graphql.GoType{ Pkg: file.GRPCSourcesPkg, Name: snakeCamelCaseSlice(pType.Enum.TypeName), Kind: reflect.Int32, }, nil } err = errors.Errorf("unknown type " + typ.String()) return } func GoPackageByPath(path, vendorPath string) (string, error) { path, err := filepath.Abs(path) if err != nil { return "", errors.Wrap(err, "failed to resolve absolute filepath") } var prefixes []string if vendorPath != "" { absVendorPath, err := filepath.Abs(vendorPath) if err != nil { return "", errors.Wrap(err, "failed to resolve absolute vendor path") } prefixes = append(prefixes, absVendorPath) } absGoPath, err := filepath.Abs(build.Default.GOPATH) if err != nil { return "", errors.Wrap(err, "failed to resolve absolute gopath") } prefixes = append(prefixes, filepath.Join(absGoPath, "src")) for _, prefix := range prefixes { if strings.HasPrefix(path, prefix) { return strings.TrimLeft(strings.TrimPrefix(path, prefix), " "+string(filepath.Separator)), nil } } return "", errors.Errorf("path '%s' is outside GOPATH or Vendor folder", path) } // Is c an ASCII lower-case letter? func isASCIILower(c byte) bool { return 'a' <= c && c <= 'z' } // Is c an ASCII digit? func isASCIIDigit(c byte) bool { return '0' <= c && c <= '9' } func camelCase(s string) string { if s == "" { return "" } t := make([]byte, 0, 32) i := 0 if s[0] == '_' { // Need a capital letter; drop the '_'. t = append(t, 'X') i++ } // Invariant: if the next letter is lower case, it must be converted // to upper case. // That is, we process a word at a time, where words are marked by _ or // upper case letter. Digits are treated as words. for ; i < len(s); i++ { c := s[i] if c == '_' && i+1 < len(s) && isASCIILower(s[i+1]) { continue // Skip the underscore in s. } if isASCIIDigit(c) { t = append(t, c) continue } // Assume we have a letter now - if not, it's a bogus identifier. // The next word is a sequence of characters that must start upper case. if isASCIILower(c) { c ^= ' ' // Make it a capital letter. } t = append(t, c) // Guaranteed not lower case. // Accept lower case sequence that follows. for i+1 < len(s) && isASCIILower(s[i+1]) { i++ t = append(t, s[i]) } } return string(t) } // camelCaseSlice is like camelCase, but the argument is a slice of strings to // be joined with "_". func camelCaseSlice(elem []string) string { return camelCase(strings.Join(elem, "")) } func snakeCamelCaseSlice(elem []string) string { return camelCase(strings.Join(elem, "_")) } func dotedTypeName(elems []string) string { return camelCase(strings.Join(elems, ".")) }
generator/plugins/proto2gql/helpers.go
0.529507
0.427038
helpers.go
starcoder
package iso20022 // Specifies periods of a corporate action. type CorporateActionPeriod10 struct { // Period during which the price of a security is determined. PriceCalculationPeriod *Period3Choice `xml:"PricClctnPrd,omitempty"` // Period during which the interest rate has been applied. InterestPeriod *Period3Choice `xml:"IntrstPrd,omitempty"` // Period during a take-over where any outstanding equity must be purchased by the take-over company. CompulsoryPurchasePeriod *Period3Choice `xml:"CmplsryPurchsPrd,omitempty"` // Period during which the security is blocked. BlockingPeriod *Period3Choice `xml:"BlckgPrd,omitempty"` // Period assigned by the court in a class action. It determines the client's eligible transactions that will be included in the class action and used to determine the resulting entitlement. ClaimPeriod *Period3Choice `xml:"ClmPrd,omitempty"` // Period defining the last date for which book entry transfers will be accepted and the date on which the suspension will be released and book entry transfer processing will resume. DepositorySuspensionPeriodForBookEntryTransfer *Period3Choice `xml:"DpstrySspnsnPrdForBookNtryTrf,omitempty"` // Period defining the last date for which deposits, into nominee name, at the agent will be accepted and the date on which the suspension will be released and deposits at agent will resume. DepositorySuspensionPeriodForDepositAtAgent *Period3Choice `xml:"DpstrySspnsnPrdForDpstAtAgt,omitempty"` // Period defining the last date for which deposits will be accepted and the date on which the suspension will be released and deposits will resume. DepositorySuspensionPeriodForDeposit *Period3Choice `xml:"DpstrySspnsnPrdForDpst,omitempty"` // Period defining the last date for which pledges will be accepted and the date on which the suspension will be released and pledge processing will resume. DepositorySuspensionPeriodForPledge *Period3Choice `xml:"DpstrySspnsnPrdForPldg,omitempty"` // Period defining the last date for which intra-position balances can be segregated and the date on which the suspension will be released and the ability to segregate intra-position balances will resume. DepositorySuspensionPeriodForSegregation *Period3Choice `xml:"DpstrySspnsnPrdForSgrtn,omitempty"` // Period defining the last date for which withdrawals, from nominee name at the agent will be accepted and the date on which the suspension will be released and withdrawals at agent processing will resume. DepositorySuspensionPeriodForWithdrawalAtAgent *Period3Choice `xml:"DpstrySspnsnPrdForWdrwlAtAgt,omitempty"` // Period defining the last date for which physical withdrawals in the nominee's name will be accepted and the date on which the suspension will be released and physical withdrawals in the nominee's name will resume. DepositorySuspensionPeriodForWithdrawalInNomineeName *Period3Choice `xml:"DpstrySspnsnPrdForWdrwlInNmneeNm,omitempty"` // Period defining the last date on which withdrawal requests in street name's will be accepted on the event security and the date on which the suspension will be released and withdrawal in street name's processing on the event security will resume. DepositorySuspensionPeriodForWithdrawalInStreetName *Period3Choice `xml:"DpstrySspnsnPrdForWdrwlInStrtNm,omitempty"` // Period defining the last date on which shareholder registration will be accepted by the issuer and the date on which shareholder registration will resume. BookClosurePeriod *Period3Choice `xml:"BookClsrPrd,omitempty"` // Period during which the settlement activities at the co-depositories are suspended in order to stabilise the holdings at the CSD. CoDepositoriesSuspensionPeriod *Period3Choice `xml:"CoDpstriesSspnsnPrd,omitempty"` // Period during which a physical certificate can be split. SplitPeriod *Period3Choice `xml:"SpltPrd,omitempty"` } func (c *CorporateActionPeriod10) AddPriceCalculationPeriod() *Period3Choice { c.PriceCalculationPeriod = new(Period3Choice) return c.PriceCalculationPeriod } func (c *CorporateActionPeriod10) AddInterestPeriod() *Period3Choice { c.InterestPeriod = new(Period3Choice) return c.InterestPeriod } func (c *CorporateActionPeriod10) AddCompulsoryPurchasePeriod() *Period3Choice { c.CompulsoryPurchasePeriod = new(Period3Choice) return c.CompulsoryPurchasePeriod } func (c *CorporateActionPeriod10) AddBlockingPeriod() *Period3Choice { c.BlockingPeriod = new(Period3Choice) return c.BlockingPeriod } func (c *CorporateActionPeriod10) AddClaimPeriod() *Period3Choice { c.ClaimPeriod = new(Period3Choice) return c.ClaimPeriod } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForBookEntryTransfer() *Period3Choice { c.DepositorySuspensionPeriodForBookEntryTransfer = new(Period3Choice) return c.DepositorySuspensionPeriodForBookEntryTransfer } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForDepositAtAgent() *Period3Choice { c.DepositorySuspensionPeriodForDepositAtAgent = new(Period3Choice) return c.DepositorySuspensionPeriodForDepositAtAgent } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForDeposit() *Period3Choice { c.DepositorySuspensionPeriodForDeposit = new(Period3Choice) return c.DepositorySuspensionPeriodForDeposit } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForPledge() *Period3Choice { c.DepositorySuspensionPeriodForPledge = new(Period3Choice) return c.DepositorySuspensionPeriodForPledge } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForSegregation() *Period3Choice { c.DepositorySuspensionPeriodForSegregation = new(Period3Choice) return c.DepositorySuspensionPeriodForSegregation } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForWithdrawalAtAgent() *Period3Choice { c.DepositorySuspensionPeriodForWithdrawalAtAgent = new(Period3Choice) return c.DepositorySuspensionPeriodForWithdrawalAtAgent } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForWithdrawalInNomineeName() *Period3Choice { c.DepositorySuspensionPeriodForWithdrawalInNomineeName = new(Period3Choice) return c.DepositorySuspensionPeriodForWithdrawalInNomineeName } func (c *CorporateActionPeriod10) AddDepositorySuspensionPeriodForWithdrawalInStreetName() *Period3Choice { c.DepositorySuspensionPeriodForWithdrawalInStreetName = new(Period3Choice) return c.DepositorySuspensionPeriodForWithdrawalInStreetName } func (c *CorporateActionPeriod10) AddBookClosurePeriod() *Period3Choice { c.BookClosurePeriod = new(Period3Choice) return c.BookClosurePeriod } func (c *CorporateActionPeriod10) AddCoDepositoriesSuspensionPeriod() *Period3Choice { c.CoDepositoriesSuspensionPeriod = new(Period3Choice) return c.CoDepositoriesSuspensionPeriod } func (c *CorporateActionPeriod10) AddSplitPeriod() *Period3Choice { c.SplitPeriod = new(Period3Choice) return c.SplitPeriod }
CorporateActionPeriod10.go
0.810366
0.607343
CorporateActionPeriod10.go
starcoder
Crankcase Pattern and Core Box */ //----------------------------------------------------------------------------- package main import ( "math" "github.com/deadsy/sdfx/sdf" ) //----------------------------------------------------------------------------- const crankcaseOuterRadius = 1.0 + (5.0 / 16.0) const crankcaseInnerRadius = 1.0 + (1.0 / 8.0) const crankcaseOuterHeight = 7.0 / 8.0 const crankcaseInnerHeight = 5.0 / 8.0 const boltLugRadius = 0.5 * (7.0 / 16.0) const mountLength = 4.75 const mountWidth = 4.75 const mountThickness = 0.25 //----------------------------------------------------------------------------- // mountLugs returns the lugs used to mount the motor. func mountLugs() sdf.SDF3 { const draft = 3.0 const thickness = 0.25 k := sdf.TruncRectPyramidParms{ Size: sdf.V3{4.75, thickness, crankcaseOuterHeight}, BaseAngle: sdf.DtoR(90 - draft), BaseRadius: crankcaseOuterHeight * 0.1, RoundRadius: crankcaseOuterHeight * 0.1, } s := sdf.TruncRectPyramid3D(&k) return sdf.Transform3D(s, sdf.Translate3d(sdf.V3{0, thickness * 0.5, 0})) } //----------------------------------------------------------------------------- func cylinderMount() sdf.SDF3 { const draft = 3.0 k := sdf.TruncRectPyramidParms{ Size: sdf.V3{2.0, 5.0 / 16.0, 1 + (3.0 / 16.0)}, BaseAngle: sdf.DtoR(90 - draft), BaseRadius: crankcaseOuterHeight * 0.1, RoundRadius: crankcaseOuterHeight * 0.1, } s := sdf.TruncRectPyramid3D(&k) return sdf.Transform3D(s, sdf.Translate3d(sdf.V3{0, crankcaseInnerRadius, 0})) } //----------------------------------------------------------------------------- // boltLugs returns lugs that hold the crankcase halves together. func boltLugs() sdf.SDF3 { const draft = 3.0 k := sdf.TruncRectPyramidParms{ Size: sdf.V3{0, 0, crankcaseOuterHeight}, BaseAngle: sdf.DtoR(90 - draft), BaseRadius: boltLugRadius, RoundRadius: crankcaseOuterHeight * 0.1, } lug := sdf.TruncRectPyramid3D(&k) // position the lugs r := crankcaseOuterRadius d := r * math.Cos(sdf.DtoR(45)) dy0 := 0.75 dx0 := -math.Sqrt(r*r - dy0*dy0) positions := sdf.V3Set{ {dx0, dy0, 0}, {1.0, 13.0 / 16.0, 0}, {-d, -d, 0}, {d, -d, 0}, } return sdf.Multi3D(lug, positions) } //----------------------------------------------------------------------------- func basePattern() sdf.SDF3 { const draft = 3.0 k := sdf.TruncRectPyramidParms{ Size: sdf.V3{0, 0, crankcaseOuterHeight}, BaseAngle: sdf.DtoR(90 - draft), BaseRadius: crankcaseOuterRadius, RoundRadius: crankcaseOuterHeight * 0.1, } body := sdf.TruncRectPyramid3D(&k) // add the bolt/mount lugs to the body with filleting s := sdf.Union3D(body, boltLugs(), mountLugs()) s.(*sdf.UnionSDF3).SetMin(sdf.PolyMin(0.1)) // cleanup the top artifacts caused by the filleting s = sdf.Cut3D(s, sdf.V3{0, 0, crankcaseOuterHeight}, sdf.V3{0, 0, -1}) // add the cylinder mount s = sdf.Union3D(s, cylinderMount()) s.(*sdf.UnionSDF3).SetMin(sdf.PolyMin(0.1)) // cleanup the bottom artifacts caused by the filleting s = sdf.Cut3D(s, sdf.V3{0, 0, 0}, sdf.V3{0, 0, 1}) return s } //----------------------------------------------------------------------------- func ccRearPattern() sdf.SDF3 { s := basePattern() return s } func ccFrontPattern() sdf.SDF3 { s := basePattern() return s } //-----------------------------------------------------------------------------
examples/midget/crankcase.go
0.693265
0.406096
crankcase.go
starcoder
package LectureService import ( "github.com/Projects/RidingTrainingSystem/internal/pkg/Lecture" "github.com/Projects/RidingTrainingSystem/internal/pkg/entity" ) // LectureService struct type LectureService struct { LectureRepo Lecture.LectureRepo } // NewLectureService function func NewLectureService(lecturerepo Lecture.LectureRepo) Lecture.LectureService { return &LectureService{ LectureRepo: lecturerepo, } } // SaveLecture (lecture *entity.Lecture) *entity.Lecture func (lectureser *LectureService) SaveLecture(lecture *entity.Lecture) *entity.Lecture { lecture, era := lectureser.LectureRepo.SaveLecture(lecture) if era != nil { return nil } return lecture } // GetLectureByID (LectureID uint) *entity.Lecture func (lectureser *LectureService) GetLectureByID(LectureID uint) *entity.Lecture { lecture, era := lectureser.LectureRepo.GetLectureByID(LectureID) if era != nil { return nil } return lecture } // PopulateLectures (lectures *[]entity.Lecture) *[]entity.Lecture func (lectureser *LectureService) PopulateLectures(lectures *[]entity.Lecture) *[]entity.Lecture { lectures, era := lectureser.LectureRepo.PopulateLectures(lectures) if era != nil { return nil } return lectures } // GetAllLecturesOfTeacherID (TeacherID uint) *[]entity.Lecture func (lectureser *LectureService) GetAllLecturesOfTeacherID(TeacherID uint) *[]entity.Lecture { lectures, era := lectureser.LectureRepo.GetAllLecturesOfTeacherID(TeacherID) if era != nil { return nil } return lectures } // GetActiveLecturesOfTeacherID (TeacherID uint) *[]entity.Lecture // it may be any round func (lectureser *LectureService) GetActiveLecturesOfTeacherID(TeacherID uint) *[]entity.Lecture { lectures, era := lectureser.LectureRepo.GetActiveLecturesOfTeacherID(TeacherID) if era != nil { return nil } return lectures } // GetActiveLecturesOfTeacherIDAndRoundID (TeacherID, RoundID uint) *[]entity.Lecture // Because the teacher Mey have many rounds that he Teaches func (lectureser *LectureService) GetActiveLecturesOfTeacherIDAndRoundID(TeacherID, RoundID uint) *[]entity.Lecture { lectures, erra := lectureser.LectureRepo.GetActiveLecturesOfTeacherIDAndRoundID(TeacherID, RoundID) if erra != nil { return nil } return lectures } // GetActiveLecturesOfRoundID (RoundID uint) *[]entity.Lecture func (lectureser *LectureService) GetActiveLecturesOfRoundID(RoundID uint) *[]entity.Lecture { lectures, era := lectureser.LectureRepo.GetActiveLecturesOfRoundID(RoundID) if era != nil { return nil } return lectures } // PassLecture to make the lecture as learned (LectureID uint) bool func (lectureser *LectureService) PassLecture(LectureID uint) bool { era := lectureser.LectureRepo.PassLecture(LectureID) if era != nil { return false } return true }
internal/pkg/Lecture/LectureService/lecture_main_service.go
0.554229
0.478407
lecture_main_service.go
starcoder
package schema // CampaignSpecSchemaJSON is the content of the file "campaign_spec.schema.json". const CampaignSpecSchemaJSON = `{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "CampaignSpec", "description": "A campaign specification, which describes the campaign and what kinds of changes to make (or what existing changesets to track).", "type": "object", "additionalProperties": false, "required": ["name"], "properties": { "name": { "type": "string", "description": "The name of the campaign, which is unique among all campaigns in the namespace. A campaign's name is case-preserving.", "pattern": "^[\\w.-]+$" }, "description": { "type": "string", "description": "The description of the campaign." }, "on": { "type": "array", "description": "The set of repositories (and branches) to run the campaign on, specified as a list of search queries (that match repositories) and/or specific repositories.", "items": { "title": "OnQueryOrRepository", "oneOf": [ { "title": "OnQuery", "type": "object", "description": "A Sourcegraph search query that matches a set of repositories (and branches). Each matched repository branch is added to the list of repositories that the campaign will be run on.", "additionalProperties": false, "required": ["repositoriesMatchingQuery"], "properties": { "repositoriesMatchingQuery": { "type": "string", "description": "A Sourcegraph search query that matches a set of repositories (and branches). If the query matches files, symbols, or some other object inside a repository, the object's repository is included.", "examples": ["file:README.md"] } } }, { "title": "OnRepository", "type": "object", "description": "A specific repository (and branch) that is added to the list of repositories that the campaign will be run on.", "additionalProperties": false, "required": ["repository"], "properties": { "repository": { "type": "string", "description": "The name of the repository (as it is known to Sourcegraph).", "examples": ["github.com/foo/bar"] }, "branch": { "type": "string", "description": "The branch on the repository to propose changes to. If unset, the repository's default branch is used." } } } ] } }, "steps": { "type": "array", "description": "The sequence of commands to run (for each repository branch matched in the ` + "`" + `on` + "`" + ` property) to produce the campaign's changes.", "items": { "title": "Step", "type": "object", "description": "A command to run (as part of a sequence) in a repository branch to produce the campaign's changes.", "additionalProperties": false, "required": ["run", "container"], "properties": { "run": { "type": "string", "description": "The shell command to run in the container. It can also be a multi-line shell script. The working directory is the root directory of the repository checkout." }, "container": { "type": "string", "description": "The Docker image used to launch the Docker container in which the shell command is run.", "examples": ["alpine:3"] }, "env": { "type": "object", "description": "Environment variables to set in the environment when running this command.", "additionalProperties": { "type": "string" } } } } }, "importChangesets": { "type": "array", "description": "Import existing changesets on code hosts.", "items": { "type": "object", "additionalProperties": false, "required": ["repository", "externalIDs"], "properties": { "repository": { "type": "string", "description": "The repository name as configured on your Sourcegraph instance." }, "externalIDs": { "type": "array", "description": "The changesets to import from the code host. For GitHub this is the PR number, for GitLab this is the MR number, for Bitbucket Server this is the PR number.", "uniqueItems": true, "items": { "oneOf": [{ "type": "string" }, { "type": "integer" }] }, "examples": [120, "120"] } } } }, "changesetTemplate": { "type": "object", "description": "A template describing how to create (and update) changesets with the file changes produced by the command steps.", "additionalProperties": false, "required": ["title", "branch", "commit", "published"], "properties": { "title": { "type": "string", "description": "The title of the changeset." }, "body": { "type": "string", "description": "The body (description) of the changeset." }, "branch": { "type": "string", "description": "The name of the Git branch to create or update on each repository with the changes." }, "commit": { "title": "ExpandedGitCommitDescription", "type": "object", "description": "The Git commit to create with the changes.", "additionalProperties": false, "required": ["message"], "properties": { "message": { "type": "string", "description": "The Git commit message." }, "author": { "title": "GitCommitAuthor", "type": "object", "description": "The author of the Git commit.", "additionalProperties": false, "required": ["name", "email"], "properties": { "name": { "type": "string", "description": "The Git commit author name." }, "email": { "type": "string", "format": "email", "description": "The Git commit author email." } } } } }, "published": { "description": "Whether to publish the changeset. An unpublished changeset can be previewed on Sourcegraph by any person who can view the campaign, but its commit, branch, and pull request aren't created on the code host. A published changeset results in a commit, branch, and pull request being created on the code host.", "oneOf": [ { "oneOf": [{ "type": "boolean" }, { "type": "string", "pattern": "^draft$" }], "description": "A single flag to control the publishing state for the entire campaign." }, { "type": "array", "description": "A list of glob patterns to match repository names. In the event multiple patterns match, the last matching pattern in the list will be used.", "items": { "type": "object", "description": "An object with one field: the key is the glob pattern to match against repository names; the value will be used as the published flag for matching repositories.", "additionalProperties": { "oneOf": [{ "type": "boolean" }, { "type": "string", "pattern": "^draft$" }] }, "minProperties": 1, "maxProperties": 1 } } ] } } } } } `
schema/campaign_spec_stringdata.go
0.811863
0.538923
campaign_spec_stringdata.go
starcoder
package radix import ( "strings" ) const glob = "*" // Label is the minimum comparing unit in the tree. type Label interface { // Match returns true if label matches the given string. Match(other string) bool // String returns the string representation. String() string // Literal returns if this label contains string literal only. Literal() bool // Wildcards returns if this label matches multiple continued tokens. Wildcards() bool } // StringLabel is the label based on string literal. type StringLabel string // Match implements the `Label` interface. func (s StringLabel) Match(other string) bool { return string(s) == other } // String implements the `Label` interface. func (s StringLabel) String() string { return string(s) } // Literal implements the `Label` interface. func (s StringLabel) Literal() bool { return true } // Wildcards implements the `Label` interface. func (s StringLabel) Wildcards() bool { return false } // globLabel is the label supposed to be matched by asterisk (*). type globLabel struct { s string parts []string wildcards bool } // String implements the `Label` interface. func (p *globLabel) String() string { return p.s } // Match implements the `Label` interface. func (p *globLabel) Match(subj string) bool { if p.s == glob { return true } if len(p.parts) == 1 { return p.s == subj } leadingGlob := strings.HasPrefix(p.s, glob) trailingGlob := strings.HasSuffix(p.s, glob) end := len(p.parts) - 1 // Go over the leading parts and ensure they match. for i := 0; i < end; i++ { idx := strings.Index(subj, p.parts[i]) switch i { case 0: // Check the first section. Requires special handling. if !leadingGlob && idx != 0 { return false } default: // Check that the middle parts match. if idx < 0 { return false } } // Trim evaluated text from subj as we loop over the pattern. subj = subj[idx + len(p.parts[i]):] } // Reached the last section. Requires special handling. return trailingGlob || strings.HasSuffix(subj, p.parts[end]) } // Literal implements the `Label` interface. func (p *globLabel) Literal() bool { return false } // Wildcards implements the `Label` interface. func (p *globLabel) Wildcards() bool { return p.wildcards } // newGlobLabel creates a glob patterned label which can use '*' to match any string. func newGlobLabel(s string) *globLabel { return &globLabel{ s: s, parts: strings.Split(s, glob), wildcards: len(s) > 1 && strings.Trim(s, glob) == "", } } // Key is the key to insert, delete, and search a tree. type Key []Label func (k Key) split(f func(Label) bool) []Key { if len(k) == 0 { return nil } out := make([]Key, 0, 2) last := -1 for i, label := range k { if f(label) { out = append(out, k[last + 1:i]) last = i } } if last >= 0 { out = append(out, k[last + 1:]) } else { out = append(out, k) } return out } func (k Key) matchExactly(x Key) bool { n := len(k) if n != len(x) { return false } for i := 0; i < n; i++ { if !k[i].Match(x[i].String()) { return false } } return true } func (k Key) captureExactly(x Key) []Key { var y []Key for i := 0; i < len(k); i++ { if !k[i].Literal() { y = append(y, Key{x[i]}) } } return y } // Match returns if key matches another one. func (k Key) Match(x Key) bool { if len(k) == 0 { return len(x) == 0 } leadingGlob := k[0].Wildcards() trailingGlob := k[len(k) - 1].Wildcards() parts := k.split(func(l Label) bool { return l.Wildcards() }) if len(parts) == 0 { return true } if len(parts) == 1 { return parts[0].matchExactly(x) } end := len(parts) - 1 // Go over the leading parts and ensure they match. for i := 0; i < end; i++ { idx := -1 y := parts[i] n := len(y) for j := 0; j + n <= len(x); j++ { if y.matchExactly(x[j : j + n]) { idx = j break } } switch i { case 0: // Check the first section. Requires special handling. if !leadingGlob && idx != 0 { return false } default: // Check that the middle parts match. if idx < 0 { return false } } // Trim evaluated label from x as we loop over the pattern. x = x[idx + n:] } // Reached the last section. Requires special handling. if trailingGlob { return true } if y := parts[end]; len(x) >= len(y) { return y.matchExactly(x[len(x) - len(y):]) } return false } // Capture returns sub-keys in which every element has a corresponding pattern in key. // This means, key `k` must be matching with given key `x`, i.e. `k.Match(x)` equals true. func (k Key) Capture(x Key) []Key { var captures []Key if len(k) == 0 { return nil } trailingGlob := k[len(k) - 1].Wildcards() parts := k.split(func(l Label) bool { return l.Wildcards() }) if len(parts) <= 1 { return parts[0].captureExactly(x) } end := len(parts) - 1 for i := 0; i < end; i++ { idx := -1 y := parts[i] n := len(y) for j := 0; j + n <= len(x); j++ { if y.matchExactly(x[j : j + n]) { idx = j break } } if idx > 0 { captures = append(captures, x[:idx]) } captures = append(captures, y.captureExactly(x[idx:idx + n])...) x = x[idx + n:] } if trailingGlob { captures = append(captures, x) } else { y := parts[end] idx := len(x) - len(y) captures = append(captures, x[:idx]) captures = append(captures, y.captureExactly(x[idx:])...) } for i := end-1; i > 0 && len(parts[i]) == 0; i-- { captures = append(captures, nil) } return captures } // Is returns if key equals given strings. func (k Key) Is(x ...string) bool { if len(k) == len(x) { for i, label := range k { if label.String() != x[i] { return false } } return true } return false } // Equal returns if key equals given strings. func (k Key) Equal(x Key) bool { if len(k) == len(x) { for i, label := range k { if label.String() != x[i].String() { return false } } return true } return false } // Wildcards returns if key contains wildcarded labels only. func (k Key) Wildcards() bool { if len(k) > 0 { for _, label := range k { if !label.Wildcards() { return false } } return true } return false } // StringWith returns a string joined with the given separator. func (k Key) StringWith(separator string) string { return strings.Join(k.Strings(), separator) } // Strings returns string slice representation. func (k Key) Strings() []string { if len(k) == 0 { return nil } s := make([]string, 0, len(k)) for _, t := range k { s = append(s, t.String()) } return s } // NewCharKey creates a general character sequenced key. func NewCharKey(s string) Key { var ( last = -1 v = make([]string, 0, len(s)) ) for i := range s { if last != -1 { v = append(v, s[last:i]) } last = i } if last != -1 { v = append(v, s[last:]) } return NewStringSliceKey(v) } // NewStringKey creates a string literal key with a separator. func NewStringKey(s, separator string) Key { return NewStringSliceKey(strings.Split(s, separator)) } // NewStringSliceKey creates a key from a string literal slice. func NewStringSliceKey(v []string) Key { labels := make([]Label, 0, len(v)) for _, s := range v { labels = append(labels, StringLabel(s)) } return labels } // NewGlobKey creates a glob patterned key from a string with a separator. func NewGlobKey(s, separator string) Key { return NewGlobSliceKey(strings.Split(s, separator)) } // NewGlobSliceKey creates a glob patterned key from a string slice. func NewGlobSliceKey(v []string) Key { labels := make([]Label, 0, len(v)) for _, s := range v { var label Label if strings.Index(s, glob) != -1 { label = newGlobLabel(s) } else { label = StringLabel(s) } labels = append(labels, label) } return labels }
x/radix/key.go
0.769687
0.422624
key.go
starcoder
package data // A Direct Acyclic Graph. // It doesn't actually check for cycles while adding nodes and links. type Dag[T comparable, D any] struct { nodes []*DagNode[T, D] } func NewDag[T comparable, D any](expectedSize int) *Dag[T, D] { return &Dag[T, D]{nodes: make([]*DagNode[T, D], 0, expectedSize)} } func (d *Dag[T, D]) AddNodes(ns ...*DagNode[T, D]) { d.nodes = append(d.nodes, ns...) } func (d *Dag[T, D]) Size() int { return len(d.nodes) } // Finds the first cycle in the DAG. // The second return tells if there's a cycle func (d *Dag[T, D]) FindCycle() ([]DagNode[T, D], bool) { whiteSet := make(map[T]*DagNode[T, D]) graySet := make(map[T]DagNode[T, D]) blackSet := make(map[T]DagNode[T, D]) parentage := make(map[T]*DagNode[T, D]) for _, node := range d.nodes { whiteSet[node.Val] = node } // depth first search var dfs func(DagNode[T, D], *DagNode[T, D]) *DagNode[T, D] dfs = func(current DagNode[T, D], parent *DagNode[T, D]) *DagNode[T, D] { delete(whiteSet, current.Val) graySet[current.Val] = current parentage[current.Val] = parent for _, neighbor := range current.Neighbors { if _, has := blackSet[neighbor.Val]; has { continue } // found cycle if _, has := graySet[neighbor.Val]; has { return &current } res := dfs(*neighbor, &current) if res != nil { return res } } delete(graySet, current.Val) blackSet[current.Val] = current return nil } for len(whiteSet) > 0 { current := FirstInMap(whiteSet) cycled := dfs(*current, nil) if cycled != nil { return d.reportCycle(*cycled, parentage), true } } return []DagNode[T, D]{}, false } // Returns a topological sorted representation of this graph. func (d *Dag[T, D]) Toposort() *Stack[DagNode[T, D]] { visited := NewSet[T]() stack := NewStack[DagNode[T, D]]() var helper func(*DagNode[T, D]) helper = func(node *DagNode[T, D]) { visited.Add(node.Val) for _, neighbor := range node.Neighbors { if visited.Contains(neighbor.Val) { continue } helper(neighbor) } stack.Push(*node) } for _, node := range ReverseSlice(d.nodes) { if visited.Contains(node.Val) { continue } helper(node) } return stack } func (d *Dag[T, D]) reportCycle(node DagNode[T, D], parentage map[T]*DagNode[T, D]) []DagNode[T, D] { cycle := []DagNode[T, D]{node} parent := parentage[node.Val] for parent != nil { cycle = append(cycle, *parent) parent = parentage[parent.Val] } return cycle } // A node in the DAG // `value` has to be unique for every node. type DagNode[T comparable, D any] struct { Val T Data D Neighbors []*DagNode[T, D] } func NewDagNode[T comparable, D any](val T, data D) *DagNode[T, D] { return &DagNode[T, D]{Val: val, Data: data} } func (n *DagNode[T, R]) Link(other *DagNode[T, R]) { n.Neighbors = append(n.Neighbors, other) } func FirstInMap[K comparable, V any](m map[K]V) V { for _, v := range m { return v } panic("map empty") }
data/dag.go
0.728748
0.614828
dag.go
starcoder
Holes */ //----------------------------------------------------------------------------- package obj import "github.com/jakoblorz/sdfx/sdf" //----------------------------------------------------------------------------- // CounterBoredHole3D returns the SDF3 for a counterbored hole. func CounterBoredHole3D( l float64, // total length (includes counterbore) r float64, // hole radius cbRadius float64, // counter bore radius cbDepth float64, // counter bore depth ) (sdf.SDF3, error) { s0, err := sdf.Cylinder3D(l, r, 0) if err != nil { return nil, err } s1, err := sdf.Cylinder3D(cbDepth, cbRadius, 0) if err != nil { return nil, err } s1 = sdf.Transform3D(s1, sdf.Translate3d(sdf.V3{0, 0, (l - cbDepth) * 0.5})) return sdf.Union3D(s0, s1), nil } // ChamferedHole3D returns the SDF3 for a chamfered hole (45 degrees). func ChamferedHole3D( l float64, // total length (includes chamfer) r float64, // hole radius chRadius float64, // chamfer radius ) (sdf.SDF3, error) { s0, err := sdf.Cylinder3D(l, r, 0) if err != nil { return nil, err } s1, err := sdf.Cone3D(chRadius, r, r+chRadius, 0) if err != nil { return nil, err } s1 = sdf.Transform3D(s1, sdf.Translate3d(sdf.V3{0, 0, (l - chRadius) * 0.5})) return sdf.Union3D(s0, s1), nil } // CounterSunkHole3D returns the SDF3 for a countersunk hole (45 degrees). func CounterSunkHole3D( l float64, // total length r float64, // hole radius ) (sdf.SDF3, error) { return ChamferedHole3D(l, r, r) } //----------------------------------------------------------------------------- // BoltCircle2D returns a 2D profile for a flange bolt circle. func BoltCircle2D( holeRadius float64, // radius of bolt holes circleRadius float64, // radius of bolt circle numHoles int, // number of bolts ) (sdf.SDF2, error) { s, err := sdf.Circle2D(holeRadius) if err != nil { return nil, err } s = sdf.Transform2D(s, sdf.Translate2d(sdf.V2{circleRadius, 0})) s = sdf.RotateCopy2D(s, numHoles) return s, nil } // BoltCircle3D returns a 3D object for a flange bolt circle. func BoltCircle3D( holeDepth float64, // depth of bolt holes holeRadius float64, // radius of bolt holes circleRadius float64, // radius of bolt circle numHoles int, // number of bolts ) (sdf.SDF3, error) { s, err := BoltCircle2D(holeRadius, circleRadius, numHoles) if err != nil { return nil, err } return sdf.Extrude3D(s, holeDepth), nil } //-----------------------------------------------------------------------------
obj/hole.go
0.817502
0.440048
hole.go
starcoder
PrettyTest is a simple testing library for golang. It aims to simplify/prettify testing in golang. It features: * a simple assertion vocabulary for better readability * customizable formatters through interfaces * before/after functions * integrated with the go test command * pretty and colorful output with reports This is the skeleton of a typical prettytest test file: package foo import ( "testing" "github.com/remogatto/prettytest" ) // Start of setup type testSuite struct { prettytest.Suite } func TestRunner(t *testing.T) { prettytest.Run( t, new(testSuite), ) } // End of setup // Tests start here func (t *testSuite) TestTrueIsTrue() { t.True(true) } See example/example_test.go and prettytest_test.go for comprehensive usage examples. */ package prettytest import ( "reflect" "regexp" "runtime" "strings" ) const ( STATUS_NO_ASSERTIONS = iota STATUS_PASS STATUS_FAIL STATUS_MUST_FAIL STATUS_PENDING ) var ( ErrorLog []*Error ) type Error struct { Suite *Suite TestFunc *TestFunc Assertion *Assertion } type callerInfo struct { name, fn string line int } func newCallerInfo(skip int) *callerInfo { pc, fn, line, ok := runtime.Caller(skip) if !ok { panic("An error occured while retrieving caller info!") } splits := strings.Split(runtime.FuncForPC(pc).Name(), ".") return &callerInfo{splits[len(splits)-1], fn, line} } type tCatcher interface { setT(t T) suite() *Suite setPackageName(name string) setSuiteName(name string) testFuncs() map[string]*TestFunc init() } func logError(error *Error) { ErrorLog = append(ErrorLog, error) } type TestFunc struct { Name, CallerName string Status int Assertions []*Assertion suite *Suite mustFail bool } type T interface { Fail() } type Suite struct { T T Package, Name string TestFuncs map[string]*TestFunc } func (s *Suite) setT(t T) { s.T = t } func (s *Suite) init() { s.TestFuncs = make(map[string]*TestFunc) } func (s *Suite) suite() *Suite { return s } func (s *Suite) setPackageName(name string) { s.Package = name } func (s *Suite) setSuiteName(name string) { s.Name = name } func (s *Suite) testFuncs() map[string]*TestFunc { return s.TestFuncs } func (s *Suite) appendTestFuncFromMethod(method *callerInfo) *TestFunc { name := method.name if _, ok := s.TestFuncs[name]; !ok { s.TestFuncs[name] = &TestFunc{ Name: name, Status: STATUS_PASS, suite: s, } } return s.TestFuncs[name] } func (s *Suite) currentTestFunc() *TestFunc { callerName := newCallerInfo(3).name if _, ok := s.TestFuncs[callerName]; !ok { s.TestFuncs[callerName] = &TestFunc{ Name: callerName, Status: STATUS_NO_ASSERTIONS, } } return s.TestFuncs[callerName] } func (testFunc *TestFunc) resetLastError() { if len(ErrorLog) > 0 { ErrorLog[len(ErrorLog)-1].Assertion.Passed = true ErrorLog = append(ErrorLog[:len(ErrorLog)-1]) testFunc.Status = STATUS_PASS for i := 0; i < len(testFunc.Assertions); i++ { if !testFunc.Assertions[i].Passed { testFunc.Status = STATUS_FAIL } } } } func (testFunc *TestFunc) logError(message string) { assertion := &Assertion{ErrorMessage: message} error := &Error{testFunc.suite, testFunc, assertion} logError(error) } func (testFunc *TestFunc) appendAssertion(assertion *Assertion) *Assertion { testFunc.Assertions = append(testFunc.Assertions, assertion) return assertion } func (testFunc *TestFunc) status() int { return testFunc.Status } func (s *Suite) setup(errorMessage string, customMessages []string) *Assertion { var message string if len(customMessages) > 0 { message = strings.Join(customMessages, "\t\t\n") } else { message = errorMessage } // Retrieve the testing method callerInfo := newCallerInfo(3) assertionName := newCallerInfo(2).name testFunc := s.appendTestFuncFromMethod(callerInfo) assertion := &Assertion{ Line: callerInfo.line, Filename: callerInfo.fn, Name: assertionName, suite: s, testFunc: testFunc, ErrorMessage: message, Passed: true, } testFunc.appendAssertion(assertion) return assertion } // Run runs the test suites. func Run(t T, suites ...tCatcher) { run(t, new(TDDFormatter), suites...) } // Run runs the test suites using the given formatter. func RunWithFormatter(t T, formatter Formatter, suites ...tCatcher) { run(t, formatter, suites...) } // Run tests. Use default formatter. func run(t T, formatter Formatter, suites ...tCatcher) { var ( beforeAllFound, afterAllFound bool beforeAll, afterAll, before, after reflect.Value totalPassed, totalFailed, totalPending, totalNoAssertions, totalExpectedFailures int ) ErrorLog = make([]*Error, 0) // flag.Parse() for _, s := range suites { beforeAll, afterAll, before, after = reflect.Value{}, reflect.Value{}, reflect.Value{}, reflect.Value{} s.setT(t) s.init() iType := reflect.TypeOf(s) splits := strings.Split(iType.String(), ".") s.setPackageName(splits[0][1:]) s.setSuiteName(splits[1]) formatter.PrintSuiteInfo(s.suite()) // search for Before and After methods for i := 0; i < iType.NumMethod(); i++ { method := iType.Method(i) if ok, _ := regexp.MatchString("^BeforeAll", method.Name); ok { if !beforeAllFound { beforeAll = method.Func beforeAllFound = true continue } } if ok, _ := regexp.MatchString("^AfterAll", method.Name); ok { if !afterAllFound { afterAll = method.Func afterAllFound = true continue } } if ok, _ := regexp.MatchString("^Before", method.Name); ok { before = method.Func } if ok, _ := regexp.MatchString("^After", method.Name); ok { after = method.Func } } if beforeAll.IsValid() { beforeAll.Call([]reflect.Value{reflect.ValueOf(s)}) } for i := 0; i < iType.NumMethod(); i++ { method := iType.Method(i) if filterMethod(method.Name) { if ok, _ := regexp.MatchString(formatter.AllowedMethodsPattern(), method.Name); ok { if before.IsValid() { before.Call([]reflect.Value{reflect.ValueOf(s)}) } method.Func.Call([]reflect.Value{reflect.ValueOf(s)}) if after.IsValid() { after.Call([]reflect.Value{reflect.ValueOf(s)}) } testFunc, ok := s.testFuncs()[method.Name] if !ok { testFunc = &TestFunc{Name: method.Name, Status: STATUS_NO_ASSERTIONS} } if testFunc.mustFail { if testFunc.Status != STATUS_FAIL { testFunc.Status = STATUS_FAIL testFunc.logError("The test was expected to fail") } else { testFunc.Status = STATUS_MUST_FAIL } } switch testFunc.Status { case STATUS_PASS: totalPassed++ case STATUS_FAIL: totalFailed++ t.Fail() case STATUS_MUST_FAIL: totalExpectedFailures++ case STATUS_PENDING: totalPending++ case STATUS_NO_ASSERTIONS: totalNoAssertions++ } formatter.PrintStatus(testFunc) } } } if afterAll.IsValid() { afterAll.Call([]reflect.Value{reflect.ValueOf(s)}) } formatter.PrintErrorLog(ErrorLog) formatter.PrintFinalReport(&FinalReport{Passed: totalPassed, Failed: totalFailed, Pending: totalPending, ExpectedFailures: totalExpectedFailures, NoAssertions: totalNoAssertions, }) } }
Godeps/_workspace/src/github.com/remogatto/prettytest/prettytest.go
0.532182
0.533033
prettytest.go
starcoder
package exponentialbackoff import ( "fmt" "time" ) const ( // initialDurationBeforeRetry is the amount of time after an error occurs // that GoroutineMap will refuse to allow another operation to start with // the same target (if exponentialBackOffOnError is enabled). Each // successive error results in a wait 2x times the previous. initialDurationBeforeRetry time.Duration = 500 * time.Millisecond // maxDurationBeforeRetry is the maximum amount of time that // durationBeforeRetry will grow to due to exponential backoff. maxDurationBeforeRetry time.Duration = 2 * time.Minute ) // ExponentialBackoff contains the last occurrence of an error and the duration // that retries are not permitted. type ExponentialBackoff struct { lastError error lastErrorTime time.Time durationBeforeRetry time.Duration } // SafeToRetry returns an error if the durationBeforeRetry period for the given // lastErrorTime has not yet expired. Otherwise it returns nil. func (expBackoff *ExponentialBackoff) SafeToRetry(operationName string) error { if time.Since(expBackoff.lastErrorTime) <= expBackoff.durationBeforeRetry { return NewExponentialBackoffError(operationName, *expBackoff) } return nil } func (expBackoff *ExponentialBackoff) Update(err *error) { if expBackoff.durationBeforeRetry == 0 { expBackoff.durationBeforeRetry = initialDurationBeforeRetry } else { expBackoff.durationBeforeRetry = 2 * expBackoff.durationBeforeRetry if expBackoff.durationBeforeRetry > maxDurationBeforeRetry { expBackoff.durationBeforeRetry = maxDurationBeforeRetry } } expBackoff.lastError = *err expBackoff.lastErrorTime = time.Now() } func (expBackoff *ExponentialBackoff) GenerateNoRetriesPermittedMsg( operationName string) string { return fmt.Sprintf("Operation for %q failed. No retries permitted until %v (durationBeforeRetry %v). Error: %v", operationName, expBackoff.lastErrorTime.Add(expBackoff.durationBeforeRetry), expBackoff.durationBeforeRetry, expBackoff.lastError) } // NewExponentialBackoffError returns a new instance of ExponentialBackoff error. func NewExponentialBackoffError( operationName string, expBackoff ExponentialBackoff) error { return exponentialBackoffError{ operationName: operationName, expBackoff: expBackoff, } } // IsExponentialBackoff returns true if an error returned from GoroutineMap // indicates that a new operation can not be started because // exponentialBackOffOnError is enabled and a previous operation with the same // operation failed within the durationBeforeRetry period. func IsExponentialBackoff(err error) bool { switch err.(type) { case exponentialBackoffError: return true default: return false } } // exponentialBackoffError is the error returned returned from GoroutineMap when // a new operation can not be started because exponentialBackOffOnError is // enabled and a previous operation with the same operation failed within the // durationBeforeRetry period. type exponentialBackoffError struct { operationName string expBackoff ExponentialBackoff } var _ error = exponentialBackoffError{} func (err exponentialBackoffError) Error() string { return fmt.Sprintf( "Failed to create operation with name %q. An operation with that name failed at %v. No retries permitted until %v (%v). Last error: %q.", err.operationName, err.expBackoff.lastErrorTime, err.expBackoff.lastErrorTime.Add(err.expBackoff.durationBeforeRetry), err.expBackoff.durationBeforeRetry, err.expBackoff.lastError) }
vendor/k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff/exponential_backoff.go
0.729423
0.415017
exponential_backoff.go
starcoder
package maps import ( "bytes" "encoding/gob" "encoding/json" "sort" "strings" ) // A StringSliceMap combines a map with a slice so that you can range over a // map in a predictable order. By default, the order will be the same order that items were inserted, // i.e. a FIFO list. This is similar to how PHP arrays work. // StringSliceMap implements the sort interface so you can change the order // before ranging over the values if desired. // It is NOT safe for concurrent use. // The zero of this is usable immediately. // The StringSliceMap satisfies the StringMapI interface. type StringSliceMap struct { items map[string]string order []string } // NewStringSliceMap creates a new map that maps string's to string's. func NewStringSliceMap() *StringSliceMap { return new (StringSliceMap) } // NewStringSliceMapFrom creates a new StringMap from a // StringMapI interface object func NewStringSliceMapFrom(i StringMapI) *StringSliceMap { m := new (StringSliceMap) m.Merge(i) return m } // NewStringSliceMapFromMap creates a new StringSliceMap from a // GO map[string]string object. Note that this will pass control of the given map to the // new object. After you do this, DO NOT change the original map. func NewStringSliceMapFromMap(i map[string]string) *StringSliceMap { m := NewStringSliceMap() m.items = i m.order = make([]string, len(m.items), len(m.items)) j := 0 for k := range m.items { m.order[j] = k j++ } return m } // SetChanged sets the value, but also appends the value to the end of the list. // It returns true if something in the map changed. If the key // was already in the map, the order will not change, but the value will be replaced. If you want the // order to change, you must Delete then call SetChanged. func (o *StringSliceMap) SetChanged(key string, val string) (changed bool) { var ok bool var oldVal string if o == nil { panic("You must initialize the map before using it.") } if o.items == nil { o.items = make(map[string]string) } if oldVal, ok = o.items[key]; !ok || oldVal != val { if !ok { o.order = append(o.order, key) } o.items[key] = val changed = true } return } // Set sets the given key to the given value. // If the key already exists, the range order will not change. func (o *StringSliceMap) Set(key string, val string) { o.SetChanged(key, val) } // SetAt sets the given key to the given value, but also inserts it at the index specified. If the index is bigger than // the length, or -1, it is the same as Set, in that it puts it at the end. Negative indexes are backwards from the // end, if smaller than the negative length, just inserts at the beginning. func (o *StringSliceMap) SetAt(index int, key string, val string) { if o == nil { panic("You must initialize the map before using it.") } if index == -1 || index >= len(o.order) { o.Set(key, val) return } var ok bool var emptyKey string if _, ok = o.items[key]; !ok { if index < -len(o.items) { index = 0 } if index < 0 { index = len(o.items) + index + 1 } o.order = append(o.order, emptyKey) copy(o.order[index+1:], o.order[index:]) o.order[index] = key } o.items[key] = val return } // Delete removes the item with the given key. func (o *StringSliceMap) Delete(key string) { if o == nil { return } for i, v := range o.order { if v == key { o.order = append(o.order[:i], o.order[i+1:]...) break } } delete(o.items, key) } // Get returns the value based on its key. If the key does not exist, an empty value is returned. func (o *StringSliceMap) Get(key string) (val string) { val,_ = o.Load(key) return } // Load returns the value based on its key, and a boolean indicating whether it exists in the map. // This is the same interface as sync.Map.Load() func (o *StringSliceMap) Load(key string) (val string, ok bool) { if o == nil { return } if o.items != nil { val, ok = o.items[key] } return } // Has returns true if the given key exists in the map. func (o *StringSliceMap) Has(key string) (ok bool) { if o == nil { return false } if o.items != nil { _, ok = o.items[key] } return } // GetAt returns the value based on its position. If the position is out of bounds, an empty value is returned. func (o *StringSliceMap) GetAt(position int) (val string) { if o == nil { return } if position < len(o.order) && position >= 0 { val, _ = o.items[o.order[position]] } return } // Values returns a slice of the values in the order they were added or sorted. func (o *StringSliceMap) Values() (vals []string) { if o == nil { return } if o.items != nil { vals = make([]string, len(o.order)) for i, v := range o.order { vals[i] = o.items[v] } } return } // Keys returns the keys of the map, in the order they were added or sorted func (o *StringSliceMap) Keys() (keys []string) { if o == nil { return } if len(o.order) != 0 { keys = make([]string, len(o.order)) for i, v := range o.order { keys[i] = v } } return } // Len returns the number of items in the map func (o *StringSliceMap) Len() int { if o == nil { return 0 } l := len(o.order) return l } // Less is part of the interface that allows the map to be sorted by values. // It returns true if the value at position i should be sorted before the value at position j. func (o *StringSliceMap) Less(i, j int) bool { return o.items[o.order[i]] < o.items[o.order[j]] } // Swap is part of the interface that allows the slice to be sorted. It swaps the positions // of the items and position i and j. func (o *StringSliceMap) Swap(i, j int) { o.order[i], o.order[j] = o.order[j], o.order[i] } // Sort by keys interface type sortStringbykeys struct { // This embedded interface permits Reverse to use the methods of // another interface implementation. sort.Interface } // A helper function to allow StringSliceMaps to be sorted by keys // To sort the map by keys, call: // sort.Sort(OrderStringStringSliceMapByKeys(m)) func OrderStringSliceMapByKeys(o *StringSliceMap) sort.Interface { return &sortStringbykeys{o} } // A helper function to allow StringSliceMaps to be sorted by keys func (r sortStringbykeys) Less(i, j int) bool { var o *StringSliceMap = r.Interface.(*StringSliceMap) return o.order[i] < o.order[j] } // Copy will make a copy of the map and a copy of the underlying data. func (o *StringSliceMap) Copy() *StringSliceMap { cp := NewStringSliceMap() o.Range(func(key string, value string) bool { cp.Set(key, value) return true }) return cp } // MarshalBinary implements the BinaryMarshaler interface to convert the map to a byte stream. func (o *StringSliceMap) MarshalBinary() (data []byte, err error) { buf := new(bytes.Buffer) encoder := gob.NewEncoder(buf) err = encoder.Encode(o.items) if err == nil { err = encoder.Encode(o.order) } data = buf.Bytes() return } // UnmarshalBinary implements the BinaryUnmarshaler interface to convert a byte stream to a // StringSliceMap func (o *StringSliceMap) UnmarshalBinary(data []byte) (err error) { var items map[string]string var order []string buf := bytes.NewBuffer(data) dec := gob.NewDecoder(buf) if err = dec.Decode(&items); err == nil { err = dec.Decode(&order) } if err == nil { o.items = items o.order = order } return err } // MarshalJSON implements the json.Marshaler interface to convert the map into a JSON object. func (o *StringSliceMap) MarshalJSON() (data []byte, err error) { // Json objects are unordered data, err = json.Marshal(o.items) return } // UnmarshalJSON implements the json.Unmarshaler interface to convert a json object to a StringMap. // The JSON must start with an object. func (o *StringSliceMap) UnmarshalJSON(data []byte) (err error) { var items map[string]string if err = json.Unmarshal(data, &items); err == nil { o.items = items // Create a default order, since these are inherently unordered o.order = make([]string, len(o.items)) i := 0 for k := range o.items { o.order[i] = k i++ } } return } // Merge the given map into the current one func (o *StringSliceMap) Merge(i StringMapI) { if i != nil { i.Range(func(k string, v string) bool { o.Set(k, v) return true }) } } // Range will call the given function with every key and value in the order // they were placed in the map, or in if you sorted the map, in your custom order. // If f returns false, it stops the iteration. This pattern is taken from sync.Map. func (o *StringSliceMap) Range(f func(key string, value string) bool) { if o == nil { return } if o.items != nil { for _, k := range o.order { if !f(k, o.items[k]) { break } } } } // Equals returns true if the map equals the given map, paying attention only to the content of the // map and not the order. func (o *StringSliceMap) Equals(i StringMapI) bool { l := i.Len() if l == 0 { return o == nil } if l != o.Len() { return false } var ret = true o.Range(func(k string, v string) bool { if !i.Has(k) || v != i.Get(k) { ret = false return false } return true }) return ret } func (o *StringSliceMap) Clear() { if o == nil {return} o.items = nil o.order = nil } func (o *StringSliceMap) IsNil() bool { return o == nil } func (o *StringSliceMap) String() string { var s string s = "{" o.Range(func(k string, v string) bool { s += `"` + k + `":"` + v+ `",` return true }) s = strings.TrimRight(s, ",") s += "}" return s } // Join is just like strings.Join func (o *StringSliceMap) Join(glue string) string { return strings.Join(o.Values(), glue) } func init() { gob.Register(new (StringSliceMap)) }
pkg/maps/strslicemap.go
0.73678
0.464112
strslicemap.go
starcoder
package number import ( "math" "reflect" ) // InRange checks whether e is present in between n to s // Supported Types : int8, uint8, uint16, int16, uint32, int32, uint64, int64, int, uint, float32, float64 func InRange(n, s, e interface{}) bool { if reflect.TypeOf(n) != reflect.TypeOf(s) || reflect.TypeOf(n) != reflect.TypeOf(e) { panic("All arguments must be of the same type!") } switch n.(type) { case uint8: return inRangeUint8(n, s, e) case int8: return inRangeInt8(n, s, e) case uint16: return inRangeUint16(n, s, e) case int16: return inRangeInt16(n, s, e) case uint32: return inRangeUint32(n, s, e) case int32: return inRangeInt32(n, s, e) case uint64: return inRangeUint64(n, s, e) case int64: return inRangeInt64(n, s, e) case uint: return inRangeUint(n, s, e) case int: return inRangeInt(n, s, e) case float32: return inRangeFloat32(n, s, e) case float64: return inRangeFloat64(n, s, e) } panic("Invalid type! The Clamp function accepts only numeric types.") } func inRangeFloat64(n interface{}, s interface{}, e interface{}) bool { return n.(float64) >= math.Min(s.(float64), e.(float64)) && n.(float64) < math.Max(s.(float64), e.(float64)) } func inRangeFloat32(n interface{}, s interface{}, e interface{}) bool { return n.(float32) >= float32(math.Min(float64(s.(float32)), float64(e.(float32)))) && n.(float32) < float32(math.Max(float64(s.(float32)), float64(e.(float32)))) } func inRangeInt(n interface{}, s interface{}, e interface{}) bool { return n.(int) >= int(math.Min(float64(s.(int)), float64(e.(int)))) && n.(int) < int(math.Max(float64(s.(int)), float64(e.(int)))) } func inRangeInt64(n interface{}, s interface{}, e interface{}) bool { return n.(int64) >= int64(math.Min(float64(s.(int64)), float64(e.(int64)))) && n.(int64) < int64(math.Max(float64(s.(int64)), float64(e.(int64)))) } func inRangeUint(n interface{}, s interface{}, e interface{}) bool { return n.(uint) >= uint(math.Min(float64(s.(uint)), float64(e.(uint)))) && n.(uint) < uint(math.Max(float64(s.(uint)), float64(e.(uint)))) } func inRangeUint64(n interface{}, s interface{}, e interface{}) bool { return n.(uint64) >= uint64(math.Min(float64(s.(uint64)), float64(e.(uint64)))) && n.(uint64) < uint64(math.Max(float64(s.(uint64)), float64(e.(uint64)))) } func inRangeInt32(n interface{}, s interface{}, e interface{}) bool { return n.(int32) >= int32(math.Min(float64(s.(int32)), float64(e.(int32)))) && n.(int32) < int32(math.Max(float64(s.(int32)), float64(e.(int32)))) } func inRangeUint32(n interface{}, s interface{}, e interface{}) bool { return n.(uint32) >= uint32(math.Min(float64(s.(uint32)), float64(e.(uint32)))) && n.(uint32) < uint32(math.Max(float64(s.(uint32)), float64(e.(uint32)))) } func inRangeInt16(n interface{}, s interface{}, e interface{}) bool { return n.(int16) >= int16(math.Min(float64(s.(int16)), float64(e.(int16)))) && n.(int16) < int16(math.Max(float64(s.(int16)), float64(e.(int16)))) } func inRangeUint16(n interface{}, s interface{}, e interface{}) bool { return n.(uint16) >= uint16(math.Min(float64(s.(uint16)), float64(e.(uint16)))) && n.(uint16) < uint16(math.Max(float64(s.(uint16)), float64(e.(uint16)))) } func inRangeInt8(n interface{}, s interface{}, e interface{}) bool { return n.(int8) >= int8(math.Min(float64(s.(int8)), float64(e.(int8)))) && n.(int8) < int8(math.Max(float64(s.(int8)), float64(e.(int8)))) } func inRangeUint8(n interface{}, s interface{}, e interface{}) bool { return n.(uint8) >= uint8(math.Min(float64(s.(uint8)), float64(e.(uint8)))) && n.(uint8) < uint8(math.Max(float64(s.(uint8)), float64(e.(uint8)))) }
number/in_range.go
0.669961
0.44083
in_range.go
starcoder
package persian import ( "fmt" "regexp" ) //ToPersianDigits Converts all English digits in the string to Persian digits. func ToPersianDigits(text string) string { var checker = map[string]string{ "0": "۰", "1": "۱", "2": "۲", "3": "۳", "4": "۴", "5": "۵", "6": "۶", "7": "۷", "8": "۸", "9": "۹", } re := regexp.MustCompile("[0-9]+") out := re.ReplaceAllFunc([]byte(text), func(s []byte) []byte { out := "" ss := string(s) for _, ch := range ss { o := checker[string(ch)] out = out + o } return []byte(out) }) return string(out) } //ToPersianDigitsFromInt Converts integer value to string with Persian digits. func ToPersianDigitsFromInt(value int) string { return ToPersianDigits(fmt.Sprintf("%d", value)) } //ToEnglishDigits Converts all Persian digits in the string to English digits. func ToEnglishDigits(text string) string { var checker = map[string]string{ "۰": "0", "۱": "1", "۲": "2", "۳": "3", "۴": "4", "۵": "5", "۶": "6", "۷": "7", "۸": "8", "۹": "9", } re := regexp.MustCompile("[۰-۹]+") out := re.ReplaceAllFunc([]byte(text), func(s []byte) []byte { out := "" ss := string(s) for _, ch := range ss { o := checker[string(ch)] out = out + o } return []byte(out) }) return string(out) } //OnlyEnglishNumbers extracts only English digits from string. func OnlyEnglishNumbers(text string) string { re := regexp.MustCompile("[^0-9.]") return re.ReplaceAllLiteralString(text, "") } //OnlyPersianNumbers extracts only Persian digits from string. func OnlyPersianNumbers(text string) string { re := regexp.MustCompile("[^۰-۹.]") return re.ReplaceAllLiteralString(text, "") } //OnlyNumbers extracts only digits from string. func OnlyNumbers(text string) string { re := regexp.MustCompile("[^۰-۹0-9.]") return re.ReplaceAllLiteralString(text, "") } //OnlyPersianAlpha extracts only persian alphabetes from string. func OnlyPersianAlpha(text string) string { re := regexp.MustCompile("[^\u0600-\u06FF.]") return re.ReplaceAllLiteralString(text, "") } //SwitchToPersianKey converts English chars to their equivalent Persian char on keyboard. func SwitchToPersianKey(text string) string { chars := map[string]string{ "q": "ض", "w": "ص", "e": "ث", "r": "ق", "t": "ف", "y": "غ", "u": "ع", "i": "ه", "o": "خ", "p": "ح", "\\[": "ج", "\\]": "چ", "a": "ش", "s": "س", "d": "ی", "f": "ب", "g": "ل", "h": "ا", "j": "ت", "k": "ن", "l": "م", ";": "ک", "'": "گ", "z": "ظ", "x": "ط", "c": "ز", "v": "ر", "b": "ذ", "n": "د", "m": "پ", ",": "و", "?": "؟", } out := "" for _, ch := range text { if pch, ok := chars[string(ch)]; ok { out += pch } else { out += string(ch) } } return ToPersianDigits(out) } //SwitchToEnglishKey converts Persian chars to their equivalent English char on keyboard. func SwitchToEnglishKey(text string) string { chars := map[string]string{ "ض": "q", "ص": "w", "ث": "e", "ق": "r", "ف": "t", "غ": "y", "ع": "u", "ه": "i", "خ": "o", "ح": "p", "ج": "\\[", "چ": "\\]", "ش": "a", "س": "s", "ی": "d", "ب": "f", "ل": "g", "ا": "h", "ت": "j", "ن": "k", "م": "l", "ک": ";", "گ": "'", "ظ": "z", "ط": "x", "ز": "c", "ر": "v", "ذ": "b", "د": "n", "پ": "m", "و": ",", "؟": "?", } out := "" for _, ch := range text { if pch, ok := chars[string(ch)]; ok { out += pch } else { out += string(ch) } } return ToEnglishDigits(out) } //FixArabic used for converting Arabic characters to Persian. func FixArabic(text string) string { chars := map[string]string{ "ي": "ی", "ك": "ک", "دِ": "د", "بِ": "ب", "زِ": "ز", "ذِ": "ذ", "ِشِ": "ش", "ِسِ": "س", "ى": "ی", } out := "" for _, ch := range text { if pch, ok := chars[string(ch)]; ok { out += pch } else { out += string(ch) } } return ToPersianDigits(out) } //Normalize used for Normalize Persian for sort and equality check. //TODO: Complete list according to Persian Collation func Normalize(text string) string { chars := map[string]string{ "ي": "ی", "ك": "ک", "دِ": "د", "بِ": "ب", "زِ": "ز", "ذِ": "ذ", "ِشِ": "ش", "ِسِ": "س", "‍":" ", "‌":" ", "ى": "ی", "ٱ":"ا" , "آ":"ا" , "ء":"ا" , "ئ":"ی" , "أ":"ا" , "ة":"ه" , } out := "" for _, ch := range text { if pch, ok := chars[string(ch)]; ok { out += pch } else { out += string(ch) } } return out } //Reverse reverses the given string. func Reverse(s string) string { runes := []rune(s) for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 { runes[i], runes[j] = runes[j], runes[i] } return string(runes) } // Currency formats number to Persian currency style. func Currency(amount string) string { countThrees := 0 out := "" _amount := []rune(OnlyNumbers(amount)) for i := len(_amount) - 1; i >= 0; i-- { if countThrees == 3 { out += "،" + string(_amount[i]) countThrees = 1 } else { out += string(_amount[i]) countThrees++ } } return ToPersianDigits(Reverse(out)) } // Toman formats number to Persian currency style with تومان postfix. func Toman(amount string) string { return Currency(amount) + " تومان" } // Rial formats number to Persian currency style with ﷼ postfix. func Rial(amount string) string { return Currency(amount) + " ﷼" } func CheckIsEnglish(text string) bool { for _, r := range text { if (r < 'a' || r > 'z') && (r < 'A' || r > 'Z') { return false } } return true }
persian.go
0.509032
0.444866
persian.go
starcoder
package main import ( sdlgfx "github.com/veandco/go-sdl2/gfx" "github.com/veandco/go-sdl2/sdl" "github.com/roeldev/go-sdl2-experiments/pkg/sdlkit" "github.com/roeldev/go-sdl2-experiments/pkg/sdlkit/geom" ) const ( MinBallRadius int32 = 10 MaxBallRadius int32 = 30 ) type ball struct { geom.Circle Vel geom.Vector // velocity (speed and direction) Acc geom.Vector // acceleration Mass float64 Color sdl.Color tx *sdl.Texture dst sdl.Rect } func newBall(rad float64, col sdl.Color) *ball { return &ball{ Circle: geom.Circle{Radius: rad}, Mass: rad * 10, Color: col, } } func (b *ball) RandPosition(w, h int32) { b.X = float64(MaxBallRadius + rng.Int31n(w-MaxBallRadius-MaxBallRadius)) b.Y = float64(MaxBallRadius + rng.Int31n(h-MaxBallRadius-MaxBallRadius)) } func (b *ball) RandVelocity(f float64) { b.Vel.X = float64(rng.Intn(300)-150) * f b.Vel.Y = float64(rng.Intn(300)-150) * f } func (b *ball) Prerender(canvas *sdlkit.Canvas) error { rad := int32(b.Radius * 4) tx, err := canvas.CreateTexture(sdl.PIXELFORMAT_RGBA8888, sdl.TEXTUREACCESS_TARGET, rad*2, rad*2) if err != nil { return err } canvas.AntiAlias(true) canvas.BeginFill(b.Color) canvas.DrawCircle(rad, rad, rad) if err = canvas.Done(); err != nil { return err } b.tx = tx b.dst = sdl.Rect{W: rad/2 + 1, H: rad/2 + 1} return nil } func (b *ball) Update(dt float64) { // add friction to acceleration b.Acc.X = b.Vel.X * -0.5 b.Acc.Y = b.Vel.Y * -0.5 // add acceleration to velocity b.Vel.X += b.Acc.X * dt b.Vel.Y += b.Acc.Y * dt // add velocity to position b.X += b.Vel.X * dt b.Y += b.Vel.Y * dt if ((b.Vel.X * b.Vel.X) + (b.Vel.Y * b.Vel.Y)) < 1 { b.Acc.Zero() b.Vel.Zero() } } func (b *ball) ClampPosition(right, bottom float64) { top, left := b.Radius, b.Radius // subtract 1 from right and bottom border to compensate for the ball's // outline thickness right -= b.Radius - 1 bottom -= b.Radius - 1 // bounce of off screen edges if needed if b.X <= left { b.X += left - b.X b.Vel.X *= -1 } else if b.X > right { b.X -= b.X - right b.Vel.X *= -1 } if b.Y <= top { b.Y += top - b.Y b.Vel.Y *= -1 } else if b.Y > bottom { b.Y -= b.Y - bottom b.Vel.Y *= -1 } } func (b *ball) Render(ren *sdl.Renderer) error { if b.tx == nil { sdlgfx.CircleColor(ren, int32(b.X), int32(b.Y), int32(b.Radius), b.Color) return nil } b.dst.X = int32(b.X - b.Radius) b.dst.Y = int32(b.Y - b.Radius) return ren.Copy(b.tx, nil, &b.dst) } func (b *ball) Destroy() error { if b.tx != nil { return b.tx.Destroy() } return nil }
collisions/olc_balls/ball.go
0.726717
0.455744
ball.go
starcoder
// Package equation implements SPOOK equations based on // the 2007 PhD thesis of <NAME> titled // "Ghosts and Machines: Regularized Variational Methods for // Interactive Simulations of Multibodies with Dry Frictional Contacts" package equation import ( "github.com/adamlenda/engine/math32" ) // IBody is the interface of all body types. type IBody interface { Index() int Position() math32.Vector3 Velocity() math32.Vector3 AngularVelocity() math32.Vector3 Force() math32.Vector3 Torque() math32.Vector3 InvMassEff() float32 InvRotInertiaWorldEff() *math32.Matrix3 } // IEquation is the interface type for all equations types. type IEquation interface { SetBodyA(IBody) BodyA() IBody SetBodyB(IBody) BodyB() IBody JeA() JacobianElement JeB() JacobianElement SetEnabled(state bool) Enabled() bool MinForce() float32 MaxForce() float32 Eps() float32 SetMultiplier(multiplier float32) ComputeB(h float32) float32 ComputeC() float32 } // Equation is a SPOOK constraint equation. type Equation struct { id int minForce float32 // Minimum (read: negative max) force to be applied by the constraint. maxForce float32 // Maximum (read: positive max) force to be applied by the constraint. bA IBody // Body "i" bB IBody // Body "j" a float32 // SPOOK parameter b float32 // SPOOK parameter eps float32 // SPOOK parameter jeA JacobianElement jeB JacobianElement enabled bool multiplier float32 // A number, proportional to the force added to the bodies. } // NewEquation creates and returns a pointer to a new Equation object. func NewEquation(bi, bj IBody, minForce, maxForce float32) *Equation { e := new(Equation) e.initialize(bi, bj, minForce, maxForce) return e } func (e *Equation) initialize(bi, bj IBody, minForce, maxForce float32) { //e.id = Equation.id++ e.minForce = minForce //-1e6 e.maxForce = maxForce //1e6 e.bA = bi e.bB = bj e.a = 0 e.b = 0 e.eps = 0 e.enabled = true e.multiplier = 0 // Set typical spook params (k, d, dt) e.SetSpookParams(1e7, 3, 1/60) } func (e *Equation) SetBodyA(ibody IBody) { e.bA = ibody } func (e *Equation) BodyA() IBody { return e.bA } func (e *Equation) SetBodyB(ibody IBody) { e.bB = ibody } func (e *Equation) BodyB() IBody { return e.bB } func (e *Equation) JeA() JacobianElement { return e.jeA } func (e *Equation) JeB() JacobianElement { return e.jeB } // SetMinForce sets the minimum force to be applied by the constraint. func (e *Equation) SetMinForce(minForce float32) { e.minForce = minForce } // MinForce returns the minimum force to be applied by the constraint. func (e *Equation) MinForce() float32 { return e.minForce } // SetMaxForce sets the maximum force to be applied by the constraint. func (e *Equation) SetMaxForce(maxForce float32) { e.maxForce = maxForce } // MaxForce returns the maximum force to be applied by the constraint. func (e *Equation) MaxForce() float32 { return e.maxForce } // Returns epsilon - the regularization constant which is multiplied by the identity matrix. func (e *Equation) Eps() float32 { return e.eps } // SetMultiplier sets the multiplier. func (e *Equation) SetMultiplier(multiplier float32) { e.multiplier = multiplier } // MaxForce returns the multiplier. func (e *Equation) Multiplier() float32 { return e.multiplier } // SetEnable sets the enabled flag of the equation. func (e *Equation) SetEnabled(state bool) { e.enabled = state } // Enabled returns the enabled flag of the equation. func (e *Equation) Enabled() bool { return e.enabled } // SetSpookParams recalculates a, b, eps. func (e *Equation) SetSpookParams(stiffness, relaxation float32, timeStep float32) { e.a = 4.0 / (timeStep * (1 + 4*relaxation)) e.b = (4.0 * relaxation) / (1 + 4*relaxation) e.eps = 4.0 / (timeStep * timeStep * stiffness * (1 + 4*relaxation)) } // ComputeB computes the RHS of the SPOOK equation. func (e *Equation) ComputeB(h float32) float32 { GW := e.ComputeGW() Gq := e.ComputeGq() GiMf := e.ComputeGiMf() return -Gq*e.a - GW*e.b - GiMf*h } // ComputeGq computes G*q, where q are the generalized body coordinates. func (e *Equation) ComputeGq() float32 { xi := e.bA.Position() xj := e.bB.Position() spatA := e.jeA.Spatial() spatB := e.jeB.Spatial() return (&spatA).Dot(&xi) + (&spatB).Dot(&xj) } // ComputeGW computes G*W, where W are the body velocities. func (e *Equation) ComputeGW() float32 { vA := e.bA.Velocity() vB := e.bB.Velocity() wA := e.bA.AngularVelocity() wB := e.bB.AngularVelocity() return e.jeA.MultiplyVectors(&vA, &wA) + e.jeB.MultiplyVectors(&vB, &wB) } // ComputeGiMf computes G*inv(M)*f, where M is the mass matrix with diagonal blocks for each body, and f are the forces on the bodies. func (e *Equation) ComputeGiMf() float32 { forceA := e.bA.Force() forceB := e.bB.Force() iMfA := forceA.MultiplyScalar(e.bA.InvMassEff()) iMfB := forceB.MultiplyScalar(e.bB.InvMassEff()) torqueA := e.bA.Torque() torqueB := e.bB.Torque() invIiTaui := torqueA.ApplyMatrix3(e.bA.InvRotInertiaWorldEff()) invIjTauj := torqueB.ApplyMatrix3(e.bB.InvRotInertiaWorldEff()) return e.jeA.MultiplyVectors(iMfA, invIiTaui) + e.jeB.MultiplyVectors(iMfB, invIjTauj) } // ComputeGiMGt computes G*inv(M)*G'. func (e *Equation) ComputeGiMGt() float32 { rotA := e.jeA.Rotational() rotB := e.jeB.Rotational() rotAcopy := e.jeA.Rotational() rotBcopy := e.jeB.Rotational() result := e.bA.InvMassEff() + e.bB.InvMassEff() result += rotA.ApplyMatrix3(e.bA.InvRotInertiaWorldEff()).Dot(&rotAcopy) result += rotB.ApplyMatrix3(e.bB.InvRotInertiaWorldEff()).Dot(&rotBcopy) return result } // ComputeC computes the denominator part of the SPOOK equation: C = G*inv(M)*G' + eps. func (e *Equation) ComputeC() float32 { return e.ComputeGiMGt() + e.eps }
experimental/physics/equation/equation.go
0.899528
0.705005
equation.go
starcoder
package sphere import ( "math" "github.com/adrianderstroff/pbr/pkg/cgm" "github.com/adrianderstroff/pbr/pkg/core/gl" mesh "github.com/adrianderstroff/pbr/pkg/view/mesh" "github.com/go-gl/mathgl/mgl32" ) // Make constructs a sphere of the specified horizontal and vertical // resolution. The resolution should be bigger or equal to 1. Also the // radius of the sphere has to be specified, it should be bigger than 0. // The mode can be gl.Triangles, gl.TriangleStrip etc. func Make(hres, vres int, radius float32, mode uint32) mesh.Mesh { geometry := makeSphereGeometry(hres, vres, radius) mesh := mesh.Make(geometry, nil, mode) return mesh } func calcUVCoordinates(pos mgl32.Vec3) (float32, float32) { dir := pos.Normalize() u := 0.5 + cgm.Atan232(dir.Z(), -dir.X())/(2*math.Pi) v := 0.5 + cgm.Asin32(dir.Y())/math.Pi return u, v } // Make creates a Sphere with the specified horizontal and vertical resolution and a radius. // The resolutions have to be 1 or greater func makeSphereGeometry(hres, vres int, radius float32) mesh.Geometry { // enforce boundary conditions hres = cgm.Maxi(hres, 1) vres = cgm.Maxi(vres, 1) // half side lengths w := 2*hres + 1 h := 2*vres + 1 var positions []float32 var uvs []float32 var normals []float32 // all other rings var rings = make([][]mgl32.Vec3, h) var tempuvs = make([][]mgl32.Vec2, h) for y := 0; y < h; y++ { rings = append(rings, make([]mgl32.Vec3, w)) tempuvs = append(tempuvs, make([]mgl32.Vec2, w)) for x := 0; x <= w; x++ { // spherical coordinates fx := float32(x) / float32(w) fy := 1.0 - float32(y)/float32(h-1) theta := 2 * math.Pi * fx phi := math.Pi * fy // spherical to cartesian px := radius * cgm.Cos32(theta) * cgm.Sin32(phi) py := radius * cgm.Cos32(phi) pz := radius * (-cgm.Sin32(theta)) * cgm.Sin32(phi) pos := mgl32.Vec3{px, py, pz} if fy == 0 { theta := 2 * math.Pi * fx phi := math.Pi * (fy + 0.001) // spherical to cartesian px := radius * cgm.Cos32(theta) * cgm.Sin32(phi) py := radius * cgm.Cos32(phi) pz := radius * (-cgm.Sin32(theta)) * cgm.Sin32(phi) // new slightly offset position pos = mgl32.Vec3{px, py, pz} } else if fy == 1 { theta := 2 * math.Pi * fx phi := math.Pi * (fy - 0.001) // spherical to cartesian px := radius * cgm.Cos32(theta) * cgm.Sin32(phi) py := radius * cgm.Cos32(phi) pz := radius * (-cgm.Sin32(theta)) * cgm.Sin32(phi) // new slightly offset position pos = mgl32.Vec3{px, py, pz} } // uv coordinates u, v := calcUVCoordinates(pos) // special case since since 360 will be mapped to 0 degree. this // would cause a visible seam because of backwards interpolation // thus we wanna explicitly set u to 1 to avoid this nasty error if x == w { u = 1 } // add to arrays rings[y] = append(rings[y], mgl32.Vec3{px, py, pz}) tempuvs[y] = append(tempuvs[y], mgl32.Vec2{u, v}) } } // create the vertex data for y := 1; y < h; y++ { for x := 1; x <= w; x++ { // ^ 1------3 // | | / | // | | / | // y 2------4 // x------> p1 := rings[y][x-1] p2 := rings[y-1][x-1] p3 := rings[y][x] p4 := rings[y-1][x] n1 := p1.Normalize() n2 := p2.Normalize() n3 := p3.Normalize() n4 := p4.Normalize() uv1 := tempuvs[y][x-1] uv2 := tempuvs[y-1][x-1] uv3 := tempuvs[y][x] uv4 := tempuvs[y-1][x] if y == h-1 { // add positions positions = append(positions, p3.X(), p3.Y(), p3.Z()) positions = append(positions, p2.X(), p2.Y(), p2.Z()) positions = append(positions, p4.X(), p4.Y(), p4.Z()) // add uvs uvs = append(uvs, uv3.X(), uv3.Y()) uvs = append(uvs, uv2.X(), uv2.Y()) uvs = append(uvs, uv4.X(), uv4.Y()) // add normals normals = append(normals, n3.X(), n3.Y(), n3.Z()) normals = append(normals, n2.X(), n2.Y(), n2.Z()) normals = append(normals, n4.X(), n4.Y(), n4.Z()) } else if y == 1 { // add positions positions = append(positions, p1.X(), p1.Y(), p1.Z()) positions = append(positions, p2.X(), p2.Y(), p2.Z()) positions = append(positions, p3.X(), p3.Y(), p3.Z()) // add uvs uvs = append(uvs, uv1.X(), uv1.Y()) uvs = append(uvs, uv2.X(), uv2.Y()) uvs = append(uvs, uv3.X(), uv3.Y()) // add normals normals = append(normals, n1.X(), n1.Y(), n1.Z()) normals = append(normals, n2.X(), n2.Y(), n2.Z()) normals = append(normals, n3.X(), n3.Y(), n3.Z()) } else { // add positions positions = append(positions, p1.X(), p1.Y(), p1.Z()) positions = append(positions, p2.X(), p2.Y(), p2.Z()) positions = append(positions, p3.X(), p3.Y(), p3.Z()) positions = append(positions, p3.X(), p3.Y(), p3.Z()) positions = append(positions, p2.X(), p2.Y(), p2.Z()) positions = append(positions, p4.X(), p4.Y(), p4.Z()) // add uvs uvs = append(uvs, uv1.X(), uv1.Y()) uvs = append(uvs, uv2.X(), uv2.Y()) uvs = append(uvs, uv3.X(), uv3.Y()) uvs = append(uvs, uv3.X(), uv3.Y()) uvs = append(uvs, uv2.X(), uv2.Y()) uvs = append(uvs, uv4.X(), uv4.Y()) // add normals normals = append(normals, n1.X(), n1.Y(), n1.Z()) normals = append(normals, n2.X(), n2.Y(), n2.Z()) normals = append(normals, n3.X(), n3.Y(), n3.Z()) normals = append(normals, n3.X(), n3.Y(), n3.Z()) normals = append(normals, n2.X(), n2.Y(), n2.Z()) normals = append(normals, n4.X(), n4.Y(), n4.Z()) } } } // setup data data := [][]float32{ positions, uvs, normals, } // setup layout layout := []mesh.VertexAttribute{ mesh.MakeVertexAttribute("pos", gl.FLOAT, 3, gl.STATIC_DRAW), mesh.MakeVertexAttribute("uv", gl.FLOAT, 2, gl.STATIC_DRAW), mesh.MakeVertexAttribute("normal", gl.FLOAT, 3, gl.STATIC_DRAW), } return mesh.MakeGeometry(layout, data) }
pkg/view/mesh/sphere/sphere.go
0.635788
0.44897
sphere.go
starcoder
package openapi import ( "encoding/json" ) // EventTypeIn struct for EventTypeIn type EventTypeIn struct { Description string `json:"description"` Name string `json:"name"` } // NewEventTypeIn instantiates a new EventTypeIn object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed func NewEventTypeIn(description string, name string, ) *EventTypeIn { this := EventTypeIn{} this.Description = description this.Name = name return &this } // NewEventTypeInWithDefaults instantiates a new EventTypeIn object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set func NewEventTypeInWithDefaults() *EventTypeIn { this := EventTypeIn{} return &this } // GetDescription returns the Description field value func (o *EventTypeIn) GetDescription() string { if o == nil { var ret string return ret } return o.Description } // GetDescriptionOk returns a tuple with the Description field value // and a boolean to check if the value has been set. func (o *EventTypeIn) GetDescriptionOk() (*string, bool) { if o == nil { return nil, false } return &o.Description, true } // SetDescription sets field value func (o *EventTypeIn) SetDescription(v string) { o.Description = v } // GetName returns the Name field value func (o *EventTypeIn) GetName() string { if o == nil { var ret string return ret } return o.Name } // GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *EventTypeIn) GetNameOk() (*string, bool) { if o == nil { return nil, false } return &o.Name, true } // SetName sets field value func (o *EventTypeIn) SetName(v string) { o.Name = v } func (o EventTypeIn) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if true { toSerialize["description"] = o.Description } if true { toSerialize["name"] = o.Name } return json.Marshal(toSerialize) } type NullableEventTypeIn struct { value *EventTypeIn isSet bool } func (v NullableEventTypeIn) Get() *EventTypeIn { return v.value } func (v *NullableEventTypeIn) Set(val *EventTypeIn) { v.value = val v.isSet = true } func (v NullableEventTypeIn) IsSet() bool { return v.isSet } func (v *NullableEventTypeIn) Unset() { v.value = nil v.isSet = false } func NewNullableEventTypeIn(val *EventTypeIn) *NullableEventTypeIn { return &NullableEventTypeIn{value: val, isSet: true} } func (v NullableEventTypeIn) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableEventTypeIn) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }
go/internal/openapi/model_event_type_in.go
0.745676
0.41561
model_event_type_in.go
starcoder