product

Vectorize the sum of outer products of coresponding columns of two matrices using Matlab/Octave

本小妞迷上赌 提交于 2019-12-10 22:45:03
问题 Suppose I have two matrices A and B which are made up of column vectors as follows. A = [a_1,a_2,...,a_N]; B = [b_1,b_2,...,b_N]; Is there any way to vectorize the calculation of the sum of outer products for every column in A with the corresponding column in B. Here is my non-vectorized solution. S = zeros(size(A,1), size(B,1)); for n=1:N S = S + A(:,n)*B(:,n)'; % S = S + a_n * b_n' end Any help would be greatly appreciated. 回答1: you are not clear on what N is, but I assume that N = number

What is the best way to prevent customers from rating a product more than once?

浪尽此生 提交于 2019-12-10 19:51:10
问题 How do I prevent a customer from rating a product more than once? Is it best to use cookies that store the IP address or is it best to store user ratings in the database? I am using MySQL and ColdFusion. Cheers! 回答1: If you have user accounts, associate your ratings with the accounts. Job done as long as one user only has one account. If you use cookies then you will likely run into problems with users who have them disabled, who use multiple browsers or who deliberately delete them, if you

Python itertools product, but conditional?

走远了吗. 提交于 2019-12-10 19:15:27
问题 I have a function fun that takes several parameters p0,p1,.. For each parameter i give a list of possible values: p0_list = ['a','b','c'] p1_list = [5,100] I can now call my function for every combination of p0,p1 for i in itertools.product(*[p0,p1]): print fun(i) Now comes the problem: What if i already know, that the parameter p1 only has an effect on the result of fun, if p0 is 'a' or 'c'? In this case i need my list of parameter combinations to look like: [('a', 5), ('a',100), ('b', 5), (

Add multiple products to cart if they are not already in cart

徘徊边缘 提交于 2019-12-10 18:55:57
问题 In WooCommerce I've implemented @jtsternberg's WooCommerce: Allow adding multiple products to the cart via the add-to-cart query string to allow adding multiple products at once, but I've received many complaints from customers who actually try to use one of the links containing multiple products. For starters, if the customer clicks checkout and then clicks the browser "back" button, all the item quantities increment. I solved this by redirecting the user to the cart URL stripped of any

woocommerce sort products by in stock and out of stock in front-end

那年仲夏 提交于 2019-12-10 18:55:08
问题 I want to show in stock products first in products category or if possible in any where and then I want to display out of stock products too after them in Woocommerce Actually there are many products which have not quantity number but those are in stock, So it is need to check in stock status, But I prefer to have more quantities first How can I make a force for current sorting in such case? Thank you very much 回答1: Using this code: <?php /** * Order product collections by stock status,

Adding a break to product title on shop pages for a certain length

余生长醉 提交于 2019-12-10 17:28:06
问题 I am trying to get more of a consistent grid layout on my shop loop. The product title spans over 1 or 2 lines depending on the string length, therefore if the string length is below the amount which forces it to overlap to the next line I want to add a break ' ' so that it doesn't affect the overall spacing of the shop loop page/ This is the code I have tried at the moment: <?php echo "test"; $title = get_the_title(); if ( strlen($title) < 29 ) { echo '<br>'; } ?> I have put it in content

Overriding properly WooCommerce function WC_Price() in a clean way

醉酒当歌 提交于 2019-12-10 17:05:04
问题 What is the best way to properly override a pre-existing WooCommerce function? In this case I want to modify the wc_price() function. I don't need to do anything crazy with it, I literally just need to add an HTML <span> attribute around the price. I know the code is as follows: function wc_price( $price, $args = array() ) { extract( apply_filters( 'wc_price_args', wp_parse_args( $args, array( 'ex_tax_label' => false, 'currency' => '', 'decimal_separator' => wc_get_price_decimal_separator(),

Dot product in an SQL table with many columns

早过忘川 提交于 2019-12-10 16:44:40
问题 I would like to multiply each row by a single specified row, and then sum that product for each row (a dot product.) My SQL table is a list of names and associated high-dimensional vectors. The table has 1 string + 1000 numerical columns. There are usually a few million rows. Each float in the vectors/arrays is in a new column: +--------+------+-------+------+---+--------+ | NAME | COL0 | COL1 | COL2 | … | COL999 | +--------+------+-------+------+---+--------+ | TOPAZ | 0.73 | 0.77 | 0.15 | |

get simple product with his options from configurable product magento

泄露秘密 提交于 2019-12-10 16:34:10
问题 How can I get a simple products (child of configurable Parent ) options (like: color = red ) if I know the simple products ID and also the parent Products ID? I am new to Magento and I really need some advice. 回答1: // load configurable product $product = Mage::getModel('catalog/product')->load($productId); // get simple produts' ids $childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId()); // get simple products $childProducts = Mage::getModel(

Fast way to get all pairs of matrix column element-wise products

送分小仙女□ 提交于 2019-12-10 16:17:16
问题 Let's say I have a numerical matrix : set.seed(1) mat <- matrix(rnorm(1000), ncol = 100) I want to generate all vectors that are the result of the element-wise product of all unique pairs of vectors in mat . How can we improve below code: all.pairs <- t(combn(1:ncol(mat), 2)) res <- do.call(cbind, lapply(1:nrow(all.pairs), function(p) mat[, all.pairs[p, 1]] * mat[, all.pairs[p, 2]])) 回答1: We could do: n <- ncol(mat) lst <- lapply(1:n, function (i) mat[,i] * mat[,i:n]) do.call(cbind, lst) Or,