dimensions

Getting unknown number of dimensions from a multidimensional array in Java

不问归期 提交于 2019-11-30 08:46:35
问题 Is it possible in Java to find the number of dimensions of an array with an 'a priori' unknown number of dimensions? That is, if one doesn't know the number of dimensions of a multidimensional matrix, how could it be retrieved, if possible? 回答1: Does anyone know if it is possible in Java to get the number of dimensions of an array with an 'a priori' unknown number of dimensions? That is, if one doesn't know the number of dimensions of a multidimensional matrix, how could it be retrieved, if

Shouldn't window.screen.width/height correspond to actual screen width/height?

廉价感情. 提交于 2019-11-30 08:46:32
问题 Toying around with the WebKit browser in the new Kindle 3G, I noticed that window.screen.width and window.screen.height don't reflect the actual screen dimensions. The physical screen (or rather, paper) dimensions are 800 x 600 . I get: 800 x 506 in landscape mode 600 x 706 in portrait mode But interestingly, both Chrome and Safari (which are also WebKit) running on my desktop report the actual screen resolution. According to MDC, these properties are not part of any specification, so there's

Swapping the dimensions of a numpy array

*爱你&永不变心* 提交于 2019-11-30 07:06:28
问题 I would like to do the following: for i in dimension1: for j in dimension2: for k in dimension3: for l in dimension4: B[k,l,i,j] = A[i,j,k,l] without the use of loops. In the end both A and B contain the same information but indexed differently. I must point out that the dimension 1,2,3 and 4 can be the same or different. So a numpy.reshape() seems difficult. 回答1: Please note: Jaime's answer is better. NumPy provides np.transpose precisely for this purpose. Or use np.einsum; this is perhaps a

JComboBox width

故事扮演 提交于 2019-11-30 06:56:59
问题 I have created a jComboBox but it takes the full width of the frame. how to set the width fixed. yes borderlayout for the frame and box layout for the panel. i am adding the code here: import javax.swing.*; import java.awt.BorderLayout; public class Window8 { JFrame frame; JPanel panel; JComboBox combo; public void go(){ String[] option = { "STUDENT", "TEACHER" }; combo.setPreferredSize(new Dimension(1,25)); combo = new JComboBox(option); menu.setSelectedIndex(0); frame = new JFrame("DELETION

When should the dimens.xml file be used in Android?

耗尽温柔 提交于 2019-11-30 06:44:09
问题 For instance, in a specific layout I have the following XML: <GridView android:id="@+id/gridView1" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="3dp" android:columnWidth="48dp" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:stretchMode="spacingWidth" /> This grid view is specific to this layout and I don't think I'll be using any other grid views with similar properties. That to say that the

Confused by document dimensions in JavaScript

白昼怎懂夜的黑 提交于 2019-11-29 23:45:34
问题 I am really confused by the different properties that exist in JavaScript for getting the dimensions of a document and how to get those numbers. Can someone recommend a good place to start to understand how I would get the size of the document and position stuff correctly? 回答1: I'll try to answer as simply as I can. The Document and Viewport In terms of geometry, there are two sets of dimensions to be aware of; the document dimensions, which reflect the entire size of the loaded page,

Get image dimensions [duplicate]

馋奶兔 提交于 2019-11-29 22:06:38
This question already has an answer here: How can I find the width of an image using PHP? 5 answers I have an url to the image, like $var = http://example.com/image.png How do I get its dimensions to an array , like array([h]=> 200, [w]=>100) (height=200, width=100) ? Sarfraz You can use the getimagesize function like this: list($width, $height) = getimagesize('path to image'); echo "width: " . $width . "<br />"; echo "height: " . $height; Using getimagesize function, we can also get these properties of that specific image- <?php list($width, $height, $type, $attr) = getimagesize("image_name

numpy array that is (n,1) and (n,)

巧了我就是萌 提交于 2019-11-29 18:57:59
问题 What is the difference between a numpy array (lets say X) that has a shape of (N,1) and (N,). Aren't both of them Nx1 matrices ? The reason I ask is because sometimes computations return either one or the other. 回答1: This is a 1D array: >>> np.array([1, 2, 3]).shape (3,) This array is a 2D but there is only one element in the first dimension: >>> np.array([[1, 2, 3]]).shape (1, 3) Transposing gives the shape you are asking for: >>> np.array([[1, 2, 3]]).T.shape (3, 1) Now, look at the array.

JFrame isResizable(false) sizing issue

三世轮回 提交于 2019-11-29 14:12:05
I intended to make a JFrame with a ContentPanel of 600x600 and I wanted the JFrame to be not re-sizable. Inside this box, I Drew a 600x600 red-outlined rectangle to make sure that everything matched when i ran the program. Before restricting resizing for the JFrame, I set the size of my JFrame by doing: getContentPane().setPreferredSize( new Dimension(600,600)); pack(); And when I launched the program and the boundaries of my rectangle fit perfectly with the dimensions of the JFrame. However, when i added isResizable(false) into the equation, there seemed to be buffer of pixels between the

How can I get the size of the android application window and not the physical screen size?

天涯浪子 提交于 2019-11-29 12:59:22
问题 In Android, how can I get the size of the app window? I'm NOT looking for the physical screen size, but the actual size of the applications window on the screen. E.g. generally what's left after you take away the notification bar, soft touch buttons, etc. 回答1: If you want the size of your app's window you can just call yourview.getHeight() and yourview.getWidth(); But the view must be drawn for that to work. If you want to get the height before it's drawn you can do this: https:/