Matrices in which row $i$ and column $i$ contain $1,\ldots,2n-1$ [closed]

For which values of $ n$ is there an $ n\times n$ matrix whose entries are $ 1,\ldots,2n-1$ such that for each $ 1 \leq i \leq n$ , the union of the $ i$ th row and $ i$ th column contains all numbers from $ 1$ to $ 2n-1$ ?

I know that this is possible whenever $ n$ is a power of 2. For example, here is a solution for $ n = 4$ : $ $ \begin{matrix} 1&2&3&4 \ 5&1&4&3 \ 6&7&1&2 \ 7&6&5&1 \end{matrix} $ $

Find the minimal subset of rows of some matrix such that the sum of each column over this rows exceeds some threshold

Let $ A$ be a an $ n\times m$ real valued matrix. The problem is to find the minimal subset $ I$ of rows (if there is any) such that the sum of each column $ j$ over the corresponding rows exceeds some threshold $ t_j$ , i.e. $ \sum_{i\in I}A[i,j]>t_j$ for all $ j\in\{1,\dots m\}$ .

Or, stated as optimization problem:

Let $ A\in\mathbb{R}^{n\times m}, t\in\mathbb{R}^m$ . Now solve \begin{align}\min_{\xi\in\{0,1\}^n}&\sum_{i=1}^n\xi_i\\text{s.t.}&\,A^\top\xi>t\,.\end{align}

Actually, i would need a solution only for $ m=2$ , but the general might be interesting too.

SQL: How to convert rows to column for every n’th row by ID

I’m trying to convert rows to columns.

I have the following columns: user_id, meta_key, meta_value

i have the following rows: 'first_name', 'last_name', 'stillingsbetegnelse'

Right now i can generate the rows and coloumns sorted and from a sepcific user_id. In my case it’s from 15. This is with the following querery

> SELECT user_id, meta_key, meta_value FROM clk_f76242643e_wp_usermeta > ORDER BY user_id DESC; where meta_key IN ('first_name', 'last_name', > 'stillingsbetegnelse') AND user_id > 15; 

And the result is:

user_id     meta_key                meta_value 16          first_name              Laxgdfds 16          last_name               Narentdsaa 16          stillingsbetegnelse     Andet 18          first_name              Riedsa 18          last_name               Joe 18          stillingsbetegnelse     Andet 

(all information is anonymized)

How do i get the following output

first_name    last_name         stillingsbetegnelse Laxgdfds      Narentdsaa        Andet Riedsa        Joe               Andet 

I have tried methods with Pivot, but i’m getting an error

    select         p.*     from clk_f76242643e_wp_usermeta     pivot(         max([meta_value])         for [meta_key] in ([first_name], [last_name], [stillingsbetegnelse]) ) as p 

3 column layout for a song site. Sidebar on left/right, and content between them

So I’m working on a website, an anime one to be precise, where people can read about anime songs, their singers, rate them/post comments to them, add them to their list etc., and this is the current layout of the site of a song.

I think it’s decent, and I’m planning to keep it this way, but I’d like to know what others, maybe some experts think about this layout.

So as you can see, on desktop view there is a sidebar menu on the left(which can’t be closed), and there is another one on the right, which contains some info about the song, such as the embedded youtube video, some statistics, info about the singer(if exists),anime, and the lyrics at the bottom. Both sidebars and the div between them are separately scrollable, but the scrollbars are hidden, because IMO it would ruin the design/layout.

And between them the content div is placed, which contains further information about the song(statistics, song recommendations, comment section etc).

Their width goes like this: 20-65-15

Desktop view

Desktop view

On mobile view, the sidebar on the right is being pushed to the top of the content div, since it perfectly fits in the screen size of a phone, and of course the menu(but without the search section) can be opened with the usual hamburger menu icon, but unlike most sites, it’s placed on the bottom.

Mobile view

Mobile view

This layout is also convenient when the user wishes to read all the comments. On that site, the layout is still the same, so the sidebar on the right is still visible. But this time it’s only visible on desktop view, so this is one privilege of those who visit the site on a PC.

Site of all comments

Do you think a layout like this would be convinent for the users? Or isn’t it too unusual to have sidebars on both sides?

RID Lookup on table with one column?

This is a simplification of a real cursor query:

DECLARE @T table (a int NOT NULL INDEX ia UNIQUE);  INSERT @T (a) VALUES (1), (5), (25), (75);  DECLARE c CURSOR LOCAL      SCROLL DYNAMIC OPTIMISTIC TYPE_WARNING FOR SELECT T.a FROM @T AS T ORDER BY T.a ASC FOR UPDATE OF a;  OPEN c;  FETCH RELATIVE 2 FROM c;  CLOSE c;  DEALLOCATE c; 

The execution plan for the FETCH shows an RID Lookup:

enter image description here

I am having trouble understanding how this plan produces the result specified by the statement:

FETCH RELATIVE 2 FROM c; 

I am most puzzled by the RID Lookup because the table has only one column, and that is returned by the Index Scan.

A detailed explanation of how the plan works would be most appreciated.

Cannot seem to access Calculated column in Display Template via Managed Property mapping

Here is my situation:

I have a test/development site on SharePoint Online/Office 365 called TestSite3, and within that site a sub-site called TestBlog3 (a Blog site for making Posts).

I want to use a Content Search Web Part on the homepage to query all Post items from the blog, and then sort them by a custom event date value, but then if event date is not specified (it will be optional), use the post’s created date.

I have also made a custom Display Template in which I have the following managed property mappings:

<mso:ManagedPropertyMapping msdt:dt="string">'Picture URL'{Picture URL}:'PublishingImage;PictureURL;PictureThumbnailURL','Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'LastModifiedTime','Line 3'{Line 3}:'BodyOWSMTXT','Line 4'{Line 4}:'RefinableDate03','SecondaryFileExtension','ContentTypeId','IsAllDayEvent'</mso:ManagedPropertyMapping> 

In the Post content type, I have added two custom columns:

  • ZTest3Date: a Date column that is optional to the user to specify, supposed to function as an ‘event date’ for posts about events coming up
  • ZTest3Calculated: a Calculated column returning a Date. What I want is for it to return the event date (ZTest3Date) if it is set, otherwise return the post’s created date (Created).

Here is the formula I have in ZTest3Calculated: =IF(ISBLANK(ZTest3Date),Created,ZTest3Date)

I have seen formulas use brackets [] around the column names, but when I try saving the formula with that it automatically removes them, leaving the above.

I go into the site’s search schema to look at the Managed and Crawled Properties. I use ‘z’ in the search box to filter them down. The ZTest3Date column I made shows up in Managed Properties as ZTest3DateOWSDATE. There is no Managed Property for the ZTest3Calculated column.

In Crawled Properties, I see ows_ZTest3Calculated, ows_ZTest3Date, and ows_q_DATE_ZTest3Date.

I can put ZTest3DateOWSDATE into my Display Template in Line 4 and it works, but that’s only half my solution; I want to handle when there is no event date set.

Since ZTest3Calculated is not available as a managed property, I understand that it is recommended to map the crawled property to one of the pre-set columns SharePoint provides, so I mapped ows_ZTest3Calculated to RefinableDate03.

I have re-indexed the Post list and waited a while, but it does not seem to be working; I have also tried assigning an alias to RefinableDate03 and updating the Display Template, still no luck. When I debug the JavaScript code I put in my display template file to read what is coming into Line 4, it is blank always, whether or not the event date is set. So either the RefinableDate03 mapping isn’t working, or my ZTest3Calculated column isn’t working. Or something else I’m not aware of.

Sorry this is so long, but I feel like supplying the context and my setup is important. I have driven myself crazy with this over the past few days, and would appreciate if someone might have some knowledge of what I’m missing.

I appreciate any help, and thank you for reading all this!

Cannot seem to access Calculated column in Display Template via Managed Property mapping

Here is my situation:

I have a test/development site on SharePoint Online/Office 365 called TestSite3, and within that site a sub-site called TestBlog3 (a Blog site for making Posts).

I want to use a Content Search Web Part on the homepage to query all Post items from the blog, and then sort them by a custom event date value, but then if event date is not specified (it will be optional), use the post’s created date.

I have also made a custom Display Template in which I have the following managed property mappings:

<mso:ManagedPropertyMapping msdt:dt="string">'Picture URL'{Picture URL}:'PublishingImage;PictureURL;PictureThumbnailURL','Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'LastModifiedTime','Line 3'{Line 3}:'BodyOWSMTXT','Line 4'{Line 4}:'RefinableDate03','SecondaryFileExtension','ContentTypeId','IsAllDayEvent'</mso:ManagedPropertyMapping> 

In the Post content type, I have added two custom columns:

  • ZTest3Date: a Date column that is optional to the user to specify, supposed to function as an ‘event date’ for posts about events coming up
  • ZTest3Calculated: a Calculated column returning a Date. What I want is for it to return the event date (ZTest3Date) if it is set, otherwise return the post’s created date (Created).

Here is the formula I have in ZTest3Calculated: =IF(ISBLANK(ZTest3Date),Created,ZTest3Date)

I have seen formulas use brackets [] around the column names, but when I try saving the formula with that it automatically removes them, leaving the above.

I go into the site’s search schema to look at the Managed and Crawled Properties. I use ‘z’ in the search box to filter them down. The ZTest3Date column I made shows up in Managed Properties as ZTest3DateOWSDATE. There is no Managed Property for the ZTest3Calculated column.

In Crawled Properties, I see ows_ZTest3Calculated, ows_ZTest3Date, and ows_q_DATE_ZTest3Date.

I can put ZTest3DateOWSDATE into my Display Template in Line 4 and it works, but that’s only half my solution; I want to handle when there is no event date set.

Since ZTest3Calculated is not available as a managed property, I understand that it is recommended to map the crawled property to one of the pre-set columns SharePoint provides, so I mapped ows_ZTest3Calculated to RefinableDate03.

I have re-indexed the Post list and waited a while, but it does not seem to be working; I have also tried assigning an alias to RefinableDate03 and updating the Display Template, still no luck. When I debug the JavaScript code I put in my display template file to read what is coming into Line 4, it is blank always, whether or not the event date is set. So either the RefinableDate03 mapping isn’t working, or my ZTest3Calculated column isn’t working. Or something else I’m not aware of.

Sorry this is so long, but I feel like supplying the context and my setup is important. I have driven myself crazy with this over the past few days, and would appreciate if someone might have some knowledge of what I’m missing.

I appreciate any help, and thank you for reading all this!