|
|
Chapter 18: Sets, Classes and RelationsIn this chapter we look at more of the built-in functions of J. The connecting theme is, somewhat loosely, working with set, classes and relations.Suppose that, for some list, for the purpose at hand, the order of the items is irrelevant and the presence of duplicate items is irrelevant. Then we can regard the list as (representing) a finite set. In the abstract, the set 3 1 2 1 is considered to be the same set as 1 2 3. The word "class" we will use in the sense in which, for example, each integer in a list belongs either to the odd class or to the even class. By "relation" is meant a table of two or more columns, expressing a relationship between a value in one column and the corresponding value in another. A relation with two columns, for example, is a set of pairs. 18.1 Sets18.1.1 MembershipThere is a built-in verb e. (lowercase e dot, called "Member"). The expresssion x e. y tests whether x matches any item of y, that is, whether x is a member of the list y. For example:
Evidently the order of items in y is irrelevant and so is the presence of duplicates in y.
We can test whether a table contains a particular row:
18.1.2 LessThere is a built-in verb -. (minus dot, called "Less"). The expression x -. y produces a list of the items of x except those which are members of y.
Evidently the order of items in y is irrelevant and so is the presence of duplicates in y. 18.1.3 NubThere is a built-in verb ~. (tilde dot, called "Nub"). The expression ~. y produces a list of the items of y without duplicates.
We can apply nub to the rows of a table:
18.1.4 Nub SieveThe verb "nub sieve" (~:) gives a boolean vector which is true only at the nub.
18.1.5 Functions for SetsThe customary functions on sets, such as set-union, set-intersection or set-equality, are easily defined using the built-in functions available. For example two sets are equal if all members of one are members of the other, and vice versa.seteq =: *./ @: (e. , e.~)
18.2 The Table AdverbRecall that the adverb / generates a verb; for example +/ is a verb which sums lists. More precisely, it is the monadic case of +/ which sums lists. The dyadic case of +/ generates a table. For example:
We see from this example that the verb + is applied to all possible combinations of an item of the left argument X with an item of the right argument Y. Here is another example: 'abc' =/ 'face' 0 1 0 0 0 0 0 0 0 0 1 0The result shows, in the first row, the value of 'a' = 'face', in the second row the value of 'b' = 'face' and so on. If we are aiming (as in the examples above) to apply the verb to all possible combinations of items from the left and items from the right, then there is a condition which must be satisfied. The condition is this. First, recall from Chapter 07 that verbs have three ranks, monadic, left and right, shown by the expression verb b. 0 . The left rank of the verb here must be the same as the rank of an item of the left argument, and the right rank of the verb must be the same as the rank of an item of the right argument. This condition can be checked by a little function , an adverb:
check =: 1 : 0 : L =. 1 { u b. 0 NB. left rank of verb u R =. 2 { u b. 0 NB. right rank of verb u assert. L = # $ 0 { x [ 'check rank of item of x' assert. R = # $ 0 { y [ 'check rank of item of y' 1 NB. OK )The condition is indeed satisfied in the examples above, because all the relevant ranks are zero: X + check Y 1Here now is an example where the condition is not satisfied. Suppose items of X and Y are scalars, and we aim to combine them by forming boxed pairs, for example with this verb:
A first attempt:
This not the result we want, because, given X and Y, the left and right the ranks of fbp don't meet the condition, that is, they are not zero, fbp b. 0 _ _ _and so the check will fail. X fbp check Y |assertion failure | L=#$0{x['check rank of item of x'The remedy is to specify the required ranks for the arguments of fbp . X fbp " 0 0 / Y +---+---+---+---+ |0 3|0 4|0 5|0 6| +---+---+---+---+ |1 3|1 4|1 5|1 6| +---+---+---+---+ |2 3|2 4|2 5|2 6| +---+---+---+---+In summary, the general scheme is that if we have z =: x f/ yand f satisfies the rank condition (check above) , then z is a table such that (< i;j){z = (i{x) f (j{y)That is, z contains all possible pairings of an item of x with an item of y. 18.3 Table DecorationsSince we have been considering tables, it might be useful here to offer one or two cookbook examples of labelling the rows and columns of a table.Firstly, suppose the data is a table of numbers: ] data =: 3 3 $ i. 9 0 1 2 3 4 5 6 7 8and that we aim to format the data with this function, which will give columns 8 digits wide: format =: 8j4 & ":suppose that the labels required are: rowlabels =: 'first'; 'second' ; 'third' collabels =: 'small'; 'medium' ; 'large'If we now compute these three values D =: < format data R =: < > rowlabels C =: < ; (_8 & {. ) (&. >) collabels(In the expression for C above, the value of_8 is for right-justifying the labels in a column-width of 8) Now we can show the data with row-labels: R,D +------+------------------------+ |first | 0.0000 1.0000 2.0000| |second| 3.0000 4.0000 5.0000| |third | 6.0000 7.0000 8.0000| +------+------------------------+or with column-labels: C ,: D +------------------------+ | small medium large| +------------------------+ | 0.0000 1.0000 2.0000| | 3.0000 4.0000 5.0000| | 6.0000 7.0000 8.0000| +------------------------+or both 2 2 $ a: , C , R ,D +------+------------------------+ | | small medium large| +------+------------------------+ |first | 0.0000 1.0000 2.0000| |second| 3.0000 4.0000 5.0000| |third | 6.0000 7.0000 8.0000| +------+------------------------+ 18.4 Classes18.4.1 Self-ClassifyConsider the problem of finding the counts of letters occurring in a string (the frequency-distribution of letters). Here is one approach.We form a table testing each letter for equality with the nub.
The expression ((nub y) = / y) can be abbreviated as (= y). The monadic case of the built-in verb = is called "Self-classify").
If we sum each row of = y we obtain the counts, in the order of the letters in the nub.
The counts can be paired with the letters of the nub:
18.4.2 Classification SchemesGardeners classify soil-types as acid, neutral or alkaline, depending on the pH value. Suppose that a pH less than 6 is classed as acid, 6 to 7 is neutral, and more than 7 as alkaline. Here now is a verb to classify a pH value, returning A for acid, N for neutral and L for alkaline (or limy).classify =: ({ & 'ANL') @: ((>: & 6) + (> & 7))
The classify function we can regard as defining a classification scheme. The letters ANL, which are in effect names of classes, are called the keys of the scheme. 18.4.3 The Key AdverbGiven some data (a list, say), we can classify each item to produce a list of corresponding keys.
We can select and group together all the data in, say, class A (all the data with key A):
Now suppose we wish to count the items in each class. That is, we aim to apply the monadic verb # separately to each group of items all of the same key. To do this we can use the built-in adverb /. (slash dot, called "Key").
For another example, instead of counting the members we could exhibit the members, by applying the box verb <.
The verb we apply can discover for itself the class of each separate argument, by classifying the first member: Here the verb u produces a boxed list: the key and count: u =: (classify @: {.) ; #
The general scheme for the "Key" adverb is as follows. In the expression x u /. y, we take y to be a list, and x is a list of keys of corresponding items of y according to some classification scheme, and u is the verb to be applied separately to each class. The scheme is: x u /. y means (= x) (u @ #) yTo illustrate: y =: 4 5 6 7 8 x =: classify y u =: <
We see that each row of =x selects items from y, and u is applied to this selection. 18.4.4 Letter-Counts RevisitedRecall the example of finding the counts of letters in a string.
Here is a variation. We note that we have in effect a classification scheme where we have as many different classes as different letters: each letter is (the key of) its own class. Thus we can write an expression of the form y u /. y. The applied verb u will see, each time, a list of letters, all the same. It counts them, with #, and takes the first, with {., to be a label for the class. u =: {. ; #
18.5 RelationsSuppose there are a number of publications, such as:
and we aim to catalog such publications. A suitable data structure for such a catalog might be a table relating authors to titles and another table relating titles to subjects. For example:
Now we choose a representation for our relations. For a first approach, we choose tables of boxed strings. The authors-titles relation is: ] AT =: (". ;. _2) 0 : 0 'Smith' ; 'Pigs' 'Brown' ; 'Pets' 'Smith' ; 'Dogs' 'James' ; 'Dogs' ) +-----+----+ |Smith|Pigs| +-----+----+ |Brown|Pets| +-----+----+ |Smith|Dogs| +-----+----+ |James|Dogs| +-----+----+and the titles-subjects relation is: ] TS =: (". ;. _2) 0 : 0 'Pigs' ; 'pigs' 'Pets' ; 'cats' 'Pets' ; 'dogs' 'Dogs' ; 'dogs' ) +----+----+ |Pigs|pigs| +----+----+ |Pets|cats| +----+----+ |Pets|dogs| +----+----+ |Dogs|dogs| +----+----+ 18.5.1 Join of RelationsFrom the authors-titles relation AT and the titles-subjects relation TS we can compute an authors-subjects relation showing which author has written a title on which subject. We say that AT and TS are to be joined with respect to titles, and we would expect the join to look like this:+-----+----+ |Smith|pigs| +-----+----+ |Brown|cats| +-----+----+ |Brown|dogs| +-----+----+ |Smith|dogs| +-----+----+ |James|dogs| +-----+----+The plan for this section is to look at a function for computing joins, then at an improved version, and then at the advantage of representing relations as tables of symbols rather than boxed strings. Finally we look at some performance comparisons. A method is as follows. We consider all possible pairs consisting of a row at from table AT and a row ts from table TS. Each pair at,ts is of the form: author; title; title; subjectIf title matches title, that is, item 1 matches item 2, then we extract author and subject, that is, items 0 and 3. Verbs for testing and extracting from at,ts pairs can be written as: test =: 1&{ = 2&{ extr =: 0 3 & {and these verbs can be plugged into a suitable conjunction to do the pairing. In writing this conjunction, we aim to avoid requiring the whole set of possible pairs to be present at the same time, since this set may be large. We also aim to avoid any duplicates in the result. Here is a first attempt. PAIR =: 2 : 0 : z =. 0 0 $ '' for_at. x do. for_ts. y do. if. u at,ts do. z =. z, v at,ts end. end. end. ~. z )The join verb can now be written as: join =: test PAIR extrand we see:
The join verb as defined above is slow, because the test and extr verbs are applied to a single x,y pair at a time - they are scalar computations. Performance will be better if we can give these verbs as much data as possible to work on at one time. (This is a universal rule in J). Vector or array arguments are better. Here is a revised vector-oriented version of PAIR and join, which still avoids building the entire set of pairs. VPAIR =: 2 : 0 : z =. 0 0 $ '' for_at. x do. z =. z , |: v (#~"1 u) |: at , "1 y end. ~. z ) vjoin =: test VPAIR extrgiving the same result as before:
Representing relations as tables of boxed strings, as above, is less than efficient. For a repeated value, the entire string is repeated. Values are compared by comparing entire strings. Now we look at another possibility. Rather than boxed strings, a relation can be represented by a table of symbols. 18.5.2 What are Symbols?Symbols are for efficient computation with string data. Symbols are a distinct data-type, in the same way that characters, boxes and numbers are distinct data-types. A symbol is a scalar which identifies, or refers to, a string.A symbol can be created by applying the built-in verb s: (lowercase s colon) to a boxed string. a =: s: <'hello'Now the variable a has a value of type symbol. We inspect this value in the usual way: a `helloand see that the value is displayed as the original string preceded by a left-quote. Even though a looks like a string when displayed, it is a scalar.
The original string is stored in a data-structure, maintained automatically by the J system, called the symbol-table. Strings are not duplicated within the symbol-table. Hence if another symbol b is created from the same string as a, then b is equal to a.
Notice that the comparison is simple scalar equality, with no need to compare the original strings. Our relations above can be converted to arrays of symbols, and joined as before.
Symbols are lexicographically ordered to reflect the ordering of the original strings. Hence tables of symbols can be sorted:
18.5.3 Measurements ComparedHere is a utility verb giving time in seconds to evaluate an expression, averaged over say 4 executions.time =: (8j5 & ":) @: (4 & (6!:2))The examples of relations above are too small for meaningful performance measurements, so we make larger relations by replicating each say 100 times. AT =: 100 $ AT TS =: 100 $ TS sAT =: 100 $ sAT sTS =: 100 $ sTSThere are 4 cases to compare: t1 =: time 'AT join TS' NB. scalar method, boxed strings t2 =: time 'sAT join sTS' NB. scalar method, symbols t3 =: time 'AT vjoin TS' NB. vector method, boxed strings t4 =: time 'sAT vjoin sTS' NB. vector method, symbolsand we see: 3 3 $ ' '; 'strings'; 'symbols';'scalar';t1;t2; 'vector';t3;t4 +------+--------+--------+ | |strings |symbols | +------+--------+--------+ |scalar| 1.06800| 0.02214| +------+--------+--------+ |vector| 0.01449| 0.00124| +------+--------+--------+In Chapter 31 we will return to the topic of performance in computing join of relations. 18.5.4 Saving and Restoring the Symbol TableSuppose that data is an array of symbols.] data =: s: 2 2 $ 'hello'; 'blah';'blah';'goodbye' `hello `blah `blah `goodbyeFor a symbol in data its original string ('hello' for example) is stored only in the symbol table, not in data itself. The original string is needed to display the value of the symbol. Suppose that we write data to a file, aiming to read it back in a new session. At the beginning of a new session, the symbol table is empty. Thus we must save the symbol table from the earlier session, and reinstate it at the beginning of the new session. First, here are two utility functions to save a value to a file and retrieve it. (See Chapter 27 and Chapter 28 for more about data in files.) save =: 4 : '(3!:1 x ) 1!:2 < y ' retr =: 3 : '3!:2 (1!:1 < y )'Save the data to a file named, say, data.xyz data save 'data.xyz'The symbol table is not itself a variable, but the expression 0 s: 10 gives a value for it. We save this value to a file named, say, symtab.xyz (0 s: 10) save 'symtab.xyz'Start a new J session. The symbol table is initially empty, so begin by reinstating it from the file saved in the earlier session: 10 s: (retr 'symtab.xyz') 1Now, with the correct symbol table in place, we can retrieve the array of symbols data from its file: DATA =: retr 'data.xyz'and we see that the symbols are correctly interpreted: DATA `hello `blah `blah `goodbyeThis is the end of Chapter 18 |
The examples in this chapter
were executed using J version 802 beta.
This chapter last updated 12 Sep 2014
Copyright © Roger Stokes 2014.
This material may be freely reproduced,
provided that acknowledgement is made.


The code is header-only and does not require any pre-built libraries, but
to avoid requiring the Boost C99 math library, you should define the macro
BOOST_ALL_NO_LIB
. For example,
in the jamfile this is done with:
<define>BOOST_ALL_NO_LIB # Avoid using 'libboost_math_c99-vc100-mt-gd-1_53.lib'.
In a preprocessor definitions, write -DBOOST_ALL_NO_LIB
You will require a Boost library to be in your include path and the SVG plot modules
<boost/svg_plot/*.hpp>
The uncertainty handling code has been stored at
<boost/quan/*.hpp>
The code of version 2 is written to comply with the C++11 standard (and use some features), and future versions will soonuse C++20 features, so recent compilers are highly recommended..
| Note | |
|---|---|
If you want to use older compilers, you should probably instead use the
1st release of this software which did not provide a full implementation
of uncertainty, but this feature requires the C++11 |
The examples have been built with
but should work on some earlier compiler releases that have good C++11 compliance.
To avoid warnings:
with GCC and Clang these options may be useful
-Wno-missing-braces, -Wno-reorder, -Wno-unused-variable
and with MSVC
/wd4800 # Forcing value to bool 'true' or 'false' /wd4996 # Deprecated. /wd4512 # Assignment operator could not be generated. /wd4127 # Expression is constant.
Other compilers like Apple Darwin and Intel have not been tested, but are likely to work OK.
The examples have been built using two IDEs:
A Boost b2 (aka bjam) jamfile.v2
is
provided in the libs/examples
folder to build all the examples
using the chosen compiler. You may like to copy and modify this to build
your own programs using b2. It contains the necessary options and warnings
disablers for the above compilers.


Shannon is 11 yrs old and attends 8th grade (Singapore Secondary 2) at K12 International School. Shannon is the lead singer for Way Past Curfew! Shannon loves to dance as well. She like atll types of dance and has studied Ballet, Broadway, Hip-Hop and Jazz. Shannon was cast to be an elf and penguin at the Base Entertainment Santa Claus the Musical which ran at the Marina Bay Sands Grand Theater in 2012. Shannon had a lead role in the mini-musical “When You are Here” which was performed in several venues in 2010, and she has the lead role in “Buy One Give One”, which had its debut in December 2011. Shannon and Christian lead worship at the International Baptist Church of Singapore.


--- layout: post status: publish published: true title: It feels good to have your own mosnter author: display_name: vishvendra login: vishvendra email<EMAIL_ADDRESS>url: '' author_login: vishvendra author_email<EMAIL_ADDRESS>wordpress_id: 456 wordpress_url: https://vishvendrasingh.com/?p=456 date: '2017-02-04 21:15:22 +0530' date_gmt: '2017-02-04 21:15:22 +0530' categories: - About Me - Computer Science tags: [] comments: - id: 109 author: bhavrndra kori author_email<EMAIL_ADDRESS>author_url: '' date: '2017-02-05 04:14:09 +0530' date_gmt: '2017-02-05 04:14:09 +0530' content: Ourself.... ---
I always dreamed of i7 processor when I saw it has 8 cores. Today own this have this monster. Its really nice if we assemble it ourself.


Brought to you by John A. Thywissen, CFI,
http://www.flyjohn.com/
© 2003, John A. Thywissen. All rights reserved.


66,1565210968,2000aaf8,00aaf800000000000000000000000000,00000000000000000000000000000000,22.5,5.2,22
67,1565210987,1f691d40,00691d40000000000000000000000000,00000000000000000000000000000000,36.7,5.6,19
68,1565211054,1f71c06c,0071c06c000000000000000000000000,00000000000000000000000000000000,33.9,6.0,67
69,1565211107,1f68e5c8,0068e5c8000000000000000000000000,00000000000000000000000000000000,36.8,6.6,53
70,1565211148,1f53d530,0053d530000000000000000000000000,00000000000000000000000000000000,46.0,7.2,41
71,1565211183,1f3e4924,003e4924000000000000000000000000,00000000000000000000000000000000,61.9,7.9,35
72,1565211254,1f4672a8,004672a8000000000000000000000000,00000000000000000000000000000000,54.7,8.7,71
73,1565211341,1f5e6bb8,005e6bb8000000000000000000000000,00000000000000000000000000000000,40.8,9.6,87
74,1565211401,1f5e6bb4,005e6bb4000000000000000000000000,00000000000000000000000000000000,40.8,10.7,60
75,1565211414,1f36d274,0036d274000000000000000000000000,00000000000000000000000000000000,70.3,12.2,13
76,1565211433,1f21b498,0021b498000000000000000000000000,00000000000000000000000000000000,114.4,14.3,19
77,1565211560,1f484858,00484858000000000000000000000000,00000000000000000000000000000000,53.3,16.8,127
78,1565211694,2000a874,00a87400000000000000000000000000,00000000000000000000000000000000,22.9,19.9,134
79,1565211698,1f506884,00506884000000000000000000000000,00000000000000000000000000000000,47.9,25.3,4
80,1565211713,1f2f7b28,002f7b28000000000000000000000000,00000000000000000000000000000000,81.2,35.9,15
81,1565211743,1f20a4a8,0020a4a8000000000000000000000000,00000000000000000000000000000000,118.1,44.6,30
82,1565211758,1f134698,00134698000000000000000000000000,00000000000000000000000000000000,200.0,51.0,15


NHS Prototype Kit
Create rapid HTML prototypes of NHS patterns.
Install
Download and Install Instructions
Tutorials & Examples
Turorials, examples and layouts.
About
About the kit, principles, privacy.
GitHub
Source code, contributing and bugs
{% extends "layout.html" %} {% block page_title %} NHS Prototyping Kit {% endblock %} {% block body %} {% block after_header %}
Create rapid HTML prototypes of NHS patterns.
Download and Install Instructions
Turorials, examples and layouts.
About the kit, principles, privacy.
Source code, contributing and bugs


Toggle navigation
Team Stats - (
)
Based on Git Commit Log (Branch:
)
Commits Timeline
Commits Distribution
Developer Stats
Release Stats
Our Commit Distribution last year (Total Commits:
, Total Reverts:
)
Commit Distribution By Calendar Units (Year,Month,Day,Hour)
Commit Distribution By Project
Revert Commit Distribution By Project
Histogram of Commit Sizes
Developer Tag Cloud
Reviewers Tag Cloud
Day of most commits
Release Composition


After graduating from Skidmore College I headed West to Los Angeles where I spent seven oddly exciting/excitingly odd years (highlights include selling a pilot to the Jim Henson Company and starring in many national commercials you fast-forwarded through while watching Breaking Bad). Seeking a career rather than a series of jobs, I then moved to St. Petersburg, FL to learn how to talk computer at The Iron Yard.
It quickly became clear that this career-shift didn't mean I had to turn my back on the Creative Process. I love the act of taking a blank lightgrey page and a series of ideas and turning that into a fully-functioning website, game, or app. I look forward to continuing to direct that passion toward countless projects to come- maybe even yours.
***
Want to work together? Me too! Shoot me a message with this form, or give me a call any time (see additional contact info below). I'll get back to you ASAP.


Welcome to our home page! We are so glad you are here! Pat has developed a recipe for a coffee-time confection called The Salmon Cookie. These cookies are made into the shape of a salmon and has just a hint of fishy goodness.
When you come by the store dont foget to pick up a Cookie Stand T-shirt, or even a salmon keychain!
Pat and his family have worked for years perfecting the Salmon Cookie. They wanted to be able to give people somthing that had never been done.
This is a true family business with all members involved. Pat's two children created the look of the cookie. Pat's wife handles all of their merchandise and design. And Pat works tirlessly trying to develope new flavors for his customers to enjoy


Before Change
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
BATCH_SIZE = 128
After Change
import io
url_base = "https://raw.githubusercontent.com/multi30k/dataset/master/data/task1/raw/"
train_urls = ("train.de.gz", "train.en.gz")
val_urls = ("val.de.gz", "val.en.gz")
test_urls = ("test_2016_flickr.de.gz", "test_2016_flickr.en.gz")
train_filepaths = [extract_archive(download_from_url(url_base + url))[0] for url in train_urls]
val_filepaths = [extract_archive(download_from_url(url_base + url))[0] for url in val_urls]
test_filepaths = [extract_archive(download_from_url(url_base + url))[0] for url in test_urls]