This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res.render('index', { | |
renderedRoot: ReactDOMServer.renderToString( | |
<Provider appData={appData}> | |
<RouterContext {...props}/> | |
</Provider> | |
), | |
appData: appData | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div id="root"><%- renderedRoot %></div> | |
<script src="/app.js"></script> | |
<script> | |
var config = { | |
appData: <%-JSON.stringify(appData)%> | |
}; | |
MY_APP.initialize(config); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window['MY_APP'] = window['MY_APP'] || (() => { | |
return { | |
initialize: (config) => { | |
ReactDOM.render( | |
<Provider appData={config.appData}> | |
<Router history={browserHistory}> | |
{ routes } | |
</Router> | |
</Provider>, | |
document.getElementById('root') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends React.Component { | |
// Encapsulate 'appData' context as props for all children | |
renderChildrenWithContextAsProps() { | |
return React.Children.map(this.props.children, (child) => { | |
return React.cloneElement(child, { | |
appData: this.context.appData | |
}); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 0, then f(x) = 5 | |
x = 1, then f(x) = 8 | |
x = 2, then f(x) = 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A(x) = a0 + a1x + a2x^2 + ... + a(n-1)x(n-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a0 + a2x^2 + a4x^4 + a(n-2)x^(n-2) | |
+ a1x + a3x^3 + a4x^4 + a(n-1)x^(n-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ae(y) = a0 + a2y + a4y^2 + a6^y3 + ... + a(n-2)y^(n-2/2) | |
Ao(y) = a1 + a3y + a5y^2 + a6^y3 + ... + a(n-1)y^(n-2/2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A(w) = Ae(w^2) + w * Ao(w^2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FFT(A, ω) | |
Input: Coefficient representation of a polynomial A(x) of degree ≤ n − 1, where n is a power of 2 | |
Output: Value representation A(ω^0), . . . , A(ω^n−1) | |
if ω = 1: return A(1) | |
express A(x) in the form Ae(x^2) + xAo(x^2) | |
call FFT(Ae, ω^2) to evaluate Ae at even powers of ω | |
call FFT(Ao, ω^2) to evaluate Ao at odd powers of ω | |
for j = 0 to n − 1: | |
compute A(ω^j) = Ae(ω^2j) + ω^jAo(ω^2j) |