Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

***
import numpy as np
>>> np.shape(a)
(2,2)
***
Also works if the input is not a numpy array but a list of lists
***
>>> a = [[1,2],[1,2]]
>>> np.shape(a)
(2,2)
***
Or a tuple of tuples
***
>>> a = ((1,2),(1,2))
>>> np.shape(a)
(2,2)
***
4 years ago
***
if (typeof image_array !== 'undefined' && image_array.length > 0) {
// the array is defined and has at least one element
}
***
Your problem may be happening due to a mix of implicit global variables and variable hoisting. Make sure you use var whenever declaring a variable:
***

// add var ^^^ here
***
And then make sure you never accidently redeclare that variable later:
***
else {
...
image_array = []; // no var here
}
***
4 years ago
In C, extern is implied for function prototypes, as a prototype declares a function which is defined somewhere else. In other words, a function prototype has external linkage by default; using extern is fine, but is redundant.

(If static linkage is required, the function must be declared as static both in its prototype and function header, and these should normally both be in the same .c file).
4 years ago
There are few possibilities:

1.printf style functions (type as an argument)
2. opengl style functions (type in function name)
3. c subset of c++ (if You can use a c++ compiler)
4 years ago
If this is what you mean, you can simply extend the class you would like to typedef, e.g.:
***
public class MyMap extends HashMap {}
***
4 years ago
A segfault is accessing memory that you're not allowed to access. It's read-only, you don't have permission, etc...

A bus error is trying to access memory that can't possibly be there. You've used an address that's meaningless to the system, or the wrong kind of address for that operation.
4 years ago
It's a hint to the compiler that the variable will be heavily used and that you recommend it be kept in a processor register if possible.

Most modern compilers do that automatically, and are better at picking them than us humans.
4 years ago
For sin specifically, using Taylor expansion would give you:

sin(x) := x - x^3/3! + x^5/5! - x^7/7! + ... (1)

you would keep adding terms until either the difference between them is lower than an accepted tolerance level or just for a finite amount of steps (faster, but less precise). An example would be something like:
***
float sin(float x)
{
float res=0, pow=x, fact=1;
for(int i=0; i<5; ++i)
{
res+=pow/fact;
pow*=-1*x*x;
fact*=(2*(i+1))*(2*(i+1)+1);
}

return res;
}
***
Note: (1) works because of the aproximation sin(x)=x for small angles. For bigger angles you need to calculate more and more terms to get acceptable results. You can use a while argument and continue for a certain accuracy:
***
double sin (double x){
int i = 1;
double cur = x;
double acc = 1;
double fact= 1;
double pow = x;
while (fabs(acc) > .00000001 && i < 100){
fact *= ((2*i)*(2*i+1));
pow *= -1 * x*x;
acc = pow / fact;
cur += acc;
i++;
}
return cur;

}
***
4 years ago
assert() function is mainly used in the debugging phase, it is tedious to write if else with a printf statement everytime you want to test a condition which might not even make its way in the final code.
4 years ago
Here's my solution, which theoretically covers all modern browsers:
***
html {
scrollbar-width: none; /* For Firefox */
-ms-overflow-style: none; /* For Internet Explorer and Edge */
}

html::-webkit-scrollbar {
width: 0px; /* For Chrome, Safari, and Opera */
}
***
4 years ago
You can set the width directly using .width() like this:
***
$("#elem").width(100);
***
Updated for comments: You have this option as well, but it'll replace all css on the element, so not sure it's any more viable:
***
$('#elem').css('cssText', 'width: 100px !important');
***
4 years ago
I think you want something like the following.
***
html, body {
height: 100%;
}
body {
margin: 0;
}
.flex-container {
height: 100%;
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
}
.row {
width: auto;
border: 1px solid blue;
}
.flex-item {
background-color: tomato;
padding: 5px;
width: 20px;
height: 20px;
margin: 10px;
line-height: 20px;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
}
***
***


1

2

3

4



***
4 years ago